美文网首页Android
Android中的Math.round(),Math.floor

Android中的Math.round(),Math.floor

作者: MoonJoy | 来源:发表于2019-02-26 17:17 被阅读267次
  • Math.round()方法: 表示的是“四舍五入”计算。
    Math.round(1.5) = 2
    Math.round(-1.5) = -1

  • Math.floor()方法: 表示的是“向下取整”计算。
    Math.floor(1.7) = 1.0
    Math.floor(-1.2) = -2.0

  • Math.ceil()方法: 表示的是“向上取整”计算。
    Math.ceil(1.3) = 2.0
    Math.ceil(-1.7) = -1.0

相关文章

网友评论

    本文标题:Android中的Math.round(),Math.floor

    本文链接:https://www.haomeiwen.com/subject/huxzyqtx.html