.net Math.Round方法详解
来源:互联网 发布:软件运营方案书 编辑:程序博客网 时间:2024/06/13 02:57
double a = 1.45;
double b = 1.55;
double c = 1.56;
double d = 1.54;context.Response.Write("a:"+Math.Round(a,1)+"<br/>"+"b:"+Math.Round(b,1)+"<br/>c:"+Math.Round(c,1)+"<br/>d:"+Math.Round(d,1));
按照传统的四舍五入的结果,a,b,c,d保留1为小数的结果是1.5,1.6,1.6,1.5。
但是输出的结果则是:
因为Math.Round采用的是四舍六入,五取偶的算法,四舍六入不需解释,五取偶的意思是,五是否进1,是根据五前面的数字判定的,五前面是偶数,则不进1,反之进1。
阅读全文
0 0
- .net Math.Round方法详解
- Math.Round()方法的四舍五入(.NET)
- Math.Round 方法
- Java Math.round方法
- Math.round()方法
- Math.round()方法
- Math.round()方法
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.round与Math.floor方法
- Math ceil()、floor()、round()方法
- Math ceil()、floor()、round()方法
- Math ceil()、floor()、round()方法
- Math ceil()、floor()、round()方法
- JavaScript中的Math.ceil()、Math.floor()、Math.round()详解
- 04:错误探测
- Android USB转串口编程
- 求1+2+3+...+n,不能利用乘除法,以及for,while,if,else;
- 如何定位JVM的问题
- iOS UIView、UIImageView旋转产生边界锯齿的完美解决方法
- .net Math.Round方法详解
- Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.hide()' on a null object re
- 分布式 微服务 JAVA语言开发
- Spring之AOP奇葩报错:Null return value from advice does not match primitive return type for
- MyBatis入门(一)
- Springmvc 拦截器的基本配置和使用
- 关于hover的一些问题
- Oracle sql生成md5
- JAVA线程之ReentrantLock源码分析(二)