1.Math.Round:四舍六入五取偶

引用内容
Math.Round(0.0) //0
Math.Round(0.1) //0
Math.Round(0.2) //0
Math.Round(0.3) //0
Math.Round(0.4) //0
Math.Round(0.5) //0
Math.Round(0.6) //1
Math.Round(0.7) //1
Math.Round(0.8) //1
Math.Round(0.9) //1

说明:对于1.5,因要返回偶数,所以结果为2。

2.Math.Ceiling:只要有小数都加1

引用内容
Math.Ceiling(0.0) //0
Math.Ceiling(0.1) //1
Math.Ceiling(0.2) //1
Math.Ceiling(0.3) //1
Math.Ceiling(0.4) //1
Math.Ceiling(0.5) //1
Math.Ceiling(0.6) //1
Math.Ceiling(0.7) //1
Math.Ceiling(0.8) //1
Math.Ceiling(0.9) //1

说明:例如在分页算法中计算分页数很有用。

3.Math.Floor:总是舍去小数

引用内容
Math.Floor(0.0) //0
Math.Floor(0.1) //0
Math.Floor(0.2) //0
Math.Floor(0.3) //0
Math.Floor(0.4) //0
Math.Floor(0.5) //0
Math.Floor(0.6) //0
Math.Floor(0.7) //0
Math.Floor(0.8) //0
Math.Floor(0.9) //0

C#取整函数Math.Round、Math.Ceiling和Math.Floor的更多相关文章

  1. js中Math.round、parseInt、Math.floor和Math.ceil小数取整总结

    Math.round.parseInt.Math.floor和Math.ceil 都可以返回一个整数,具体的区别请看下面的总结. 一.Math.round 作用:四舍五入,返回参数+0.5后,向下取整 ...

  2. js中Math.round、parseInt、Math.floor和Math.ceil小数取整小结

    以前经常在代码中看到Math.round.parseInt.Math.floor和Math.ceil这四个函数,虽然知道结果都可以返回一个整数,但是对他们四者的区别还是不太清楚,今天就做一个小结. 一 ...

  3. js中Math.round、parseInt、Math.floor和Math.ceil小数取整小结【转】

    [摘要:之前常常正在代码中看到Math.round.parseInt.Math.floor战Math.ceil那四个函数,固然晓得效果皆能够返回一个整数,然则对他们四者的差别照样没有太清晰,本日便做一 ...

  4. js中Math.round、parseInt、Math.floor和Math.ceil小数取整总结(转)

    js中Math.round.parseInt.Math.floor和Math.ceil小数取整总结 Math.round.parseInt.Math.floor和Math.ceil 都可以返回一个整数 ...

  5. int和integer;Math.round(11.5)和Math.round(-11.5)

    int是java提供的8种原始数据类型之一.Java为每个原始类型提供了封装类,Integer是java为int提供的封装类.int的默认值为0,而Integer的默认值为null,即Integer可 ...

  6. C#取整函数Math.Round、Math.Ceiling和Math.Floor 【非原创,用来收藏,分享】

    1.Math.Round:四舍六入五取偶 引用内容 Math.Round(0.0) //0Math.Round(0.1) //0Math.Round(0.2) //0Math.Round(0.3) / ...

  7. Math.Round四舍六入五取偶Math.Ceiling只要有小数都加1Math.Floor总是舍去小数

    1.Math.Round:四舍六入五取偶 引用内容 Math.Round(0.0) //0Math.Round(0.1) //0Math.Round(0.2) //0Math.Round(0.3) / ...

  8. java基础之二:取整函数(Math类)

    在日常开发中经常会遇到数字的情况,有关数据的场景中会遇到取整的情况,java中提供了取整函数.看下java.lang.Math类中取整函数的用法. 一.概述 java.lang.Math类中有三个和取 ...

  9. Javascript四舍五入(Math.round()与Math.pow())

    代码 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ ...

随机推荐

  1. newifi mini将led指示灯引出当gpio使用

    之前买了个newifi mini的路由器,CPU是mt7620a的,有7个led指示灯.现在想要把控制led灯的gpio引出来,方便其他驱动或应用的开发. 一.硬件部分 1.联想路由 现在想要把USB ...

  2. pandas初识

    pandas初识 1.生成DataFrame型的数据 import pandas as pd import numpy as np dates = pd.date_range('20130101',p ...

  3. SQL 行列转置

    ),),[Score] int) Insert Class union all union all union all union all union all union all union all ...

  4. RGB颜色空间、HSV颜色空间的理解

    HSV是把H(色相),S(饱和度),V(亮度)当做色值来定位颜色的空间. 1.HSV模型 色相:取值范围是0~360度,用来表示颜色的类别.其中红色是0度,绿色是120度,蓝色是240度.饱和度:取值 ...

  5. Winform 界面全屏 显示状态栏

    this.FormBorderStyle = FormBorderStyle.None; this.MaximumSize = new Size(Screen.PrimaryScreen.Workin ...

  6. DS图--最小生成树

    题目描述 根据输入创建无向网.分别用Prim算法和Kruskal算法构建最小生成树.(假设:输入数据的最小生成树唯一.) 输入 顶点数n n个顶点 边数m m条边信息,格式为:顶点1 顶点2 权值 P ...

  7. 【springboot】之常用技术文档

    https://www.ibm.com/developerworks/cn/java/j-lo-spring-boot/index.html

  8. eclipse安装、汉化、搭建安卓开发环境

    1.eclipse与jdk的位数(32bit or 64bit )要对应,否则会提示Failed to load JNI shared library.提示这一种错误据说还有另外一种原因就是Path路 ...

  9. 注入 - Ring3 APC注入

    系统产生一个软中断,当线程再次被唤醒时,此线程会首先执行APC队列中的被注册的函数,利用QueueUserAPC()这个API,并以此去执行我们的DLL加载代码,进而完成DLL注入的目的, 1.根据进 ...

  10. Hive深入学习--应用场景及架构原理

    Hive背景介绍 Hive最初是Facebook为了满足对海量社交网络数据的管理和机器学习的需求而产生和发展的.互联网现在进入了大数据时代,大数据是现在互联网的趋势,而hadoop就是大数据时代里的核 ...