C#-Math.Round()
来源:互联网 发布:股票分析算法 编辑:程序博客网 时间:2024/06/06 02:26
1、向上取整:math.ceiling()
例如:math.ceiling(1) = 1
math.ceiling(1.1) = 2
math.ceiling(1.5) = 2
2、向下取整:math.floor()
例如:math.floor(1) = 1
math.floor(1.1) = 1
math.floor(1.5) = 1
3、四舍五入(四舍六入五取偶): Math.Round()
例如:Math.Round(0.5,0)=0
Math.Round(1.5,0)=2
Math.Round(2.5,0)=2
Math.Round(3.5,0)=4
准确的说,不是四舍五入,而是四舍六入无凑偶,就是说小于4大于6该舍就舍该入就入,没有争议,而无处于正中间,如果四舍五入会造成数据整体偏差,所以采取的原则是:如果舍入位为5,就去最近的偶数。
4、 直接切下整数trunc
例如:比如 trunc(-123.55)=-123, floor(123.55)=123
5、返回绝对值:math.abs()
- C#-Math.Round()
- Math.round()
- Math.Round
- Math.round
- Math.round()
- Math.Round
- Math.Round()
- Math.round()
- Codeforces Beta Round #32 (Div. 2) C (math+思维)
- Codeforces Round #328 (Div. 2) C. The Big Race (math)
- math。round and math。floor
- Math.ceil()和Math.floor()、Math.round()
- Math.round|Math.floor|Math.ceil区别
- Math.floor,Math.round,Math.ceil
- Math.round, Math.ceil 和 Math.floor
- Math.floor()/Math.ceil()/Math.round()
- Math.ceil、Math.floor、Math.round用法
- Math.Round函数说明
- Java 并发编程:volatile的使用及其原理
- 高中OJ1302. DigitalCounter
- TCP/IP详解学习笔记(1)-基本概念
- css的基本选择器
- python之路——list操作
- C#-Math.Round()
- 中文乱码解决
- python_time模块
- Perl 字符串截取函数substr
- 卸载Oracle数据库
- 我的第一篇博客
- Spring Boot 注意问题
- java-未捕获异常的处理
- 根据类(不能被继承、只能在栈上/堆上创建对象)的特点设计一个类