07 2011 档案
javascript浮点运算问题
摘要:在判断浮点运算结果前对计算结果进行精度缩小,因为在精度缩小的过程总会自动四舍五入;(1.0-0.9).toFixed(digits) toFixed() 精度参数须在 0 与20 之间 如 (1.0-0.9).toFixed(10)==0.1 ,结果为True 阅读全文
posted @ 2011-07-26 11:13 jameshappy 阅读(154) 评论(0) 推荐(0)
随机数生成
摘要:for (int j = 0; j < 8; j++) { String charOrNum = ran.Next(2) % 2 == 0 ? "char" : "num"; // 输出字母还是数字 if (charOrNum=="char") // 字符串 { int choice = ran.Next(2) % 2 == 0 ? 65 : 97; //取得大写字母还是小写字母 val += (char)(choice + ran.Next(26)); } else // 数字 { val += ran.Next(10).To 阅读全文
posted @ 2011-07-21 12:41 jameshappy 阅读(213) 评论(0) 推荐(0)