IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    java中的几种取整函数

    summer发表于 2016-11-09 06:53:04
    love 0
    舍掉小数取整:Math.floor(2)=2
    舍掉小数取整:Math.floor(2.1)=2
    舍掉小数取整:Math.floor(2.5)=2
    舍掉小数取整:Math.floor(2.9)=2
    负数舍掉小数取整:Math.floor(-2)=-2
    负数舍掉小数取整:Math.floor(-2.1)=-3
    负数舍掉小数取整:Math.floor(-2.5)=-3
    负数舍掉小数取整:Math.floor(-2.9)=-3

    见小数取整:Math.ceil(2)=2
    见小数取整:Math.ceil(2.1)=3
    见小数取整:Math.ceil(2.5)=3
    见小数取整:Math.ceil(2.9)=3

    负数见小数取整:Math.ceil(-2)=-2
    负数见小数取整:Math.ceil(-2.1)=-2
    负数见小数取整:Math.ceil(-2.5)=-2
    负数见小数取整:Math.ceil(-2.9)=-2

      



沪ICP备19023445号-2号
友情链接