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. Android-Java-封装

    先看一个未封装的Demo案例一: package android.java.oop03; class Person { int age; } public class PottingDemo { pu ...

  2. Crontab有关

    AIX下面 0,2,4,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,58 * * * * /usr/s ...

  3. 开发 C# OPC 客户端

    编写 opc 客户端的思路 1. 使用OPC Client浏览服务器, 查看测试代码修改后的结果. 2. 根据OPC Client搜集到的服务器信息编写代码和服务器交互 3. OPC Client 操 ...

  4. 绿色版Mysql自动建立my.ini和命令行启动并动态指定datadir路径

    1.先去下载绿色版的Mysql(https://cdn.mysql.com//archives/mysql-5.7/mysql-5.7.20-winx64.zip) 2.解压缩到任意目录(如D:\My ...

  5. JS中图片飞飞效果

    当鼠标在界面上移动的时候,后面有一连串的图片跟随者一起飘动,效果如下: 实现的基本思想:准备五个img标签,为了方便控制都放在一个div里面,设置div的定位方式为 fixed,设置成这中定位方式主要 ...

  6. WPF ListBox的进阶使用(一)

    公司项目有个需求,UI界面支持动态平均分割界面,想了想便想到用ListBox来实现,用UniformGrid作为ListBox的ItemsPanelTemplate,通过动态改变UniformGrid ...

  7. 【转】OAuth的改变

    原文地址:http://huoding.com/2011/11/08/126 去年我写过一篇<OAuth那些事儿>,对OAuth做了一些简单扼要的介绍,今天我打算写一些细节,以阐明OAut ...

  8. 【新手向】阿里云上ubuntu+flask+gunicorn+nginx服务器部署(二)项目部署

    本项目实现的是类似于ins的图片分享网站.继续(一),当nginx的配置已修改好后,要在远程服务器上部署网站,只需要几个步骤: 1 前期准备 2 将运行网站的代码从github上下载过来 3 下载依赖 ...

  9. diamond的设计思路

    diamond主要包含四个包:diamond-client.diamond-sdk.diamond-server和diamond-util client就非常简单的进行http的调用server拿数据 ...

  10. Java内存溢出问题总结

    使用Java那么久,在此总结一下Java中常见的内存溢出问题以及对应的解决思路 堆溢出 报错信息 java.lang.OutOfMemoryError: Java heap space 报错原因 堆中 ...