`
lxr215
  • 浏览: 58876 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

java.lang.Math类中round()和floor()区别

    博客分类:
  • Java
阅读更多
public static int round
(floata);
public static long round
(doublea);
public static double floor
(doublea);
 round实际相当于(int)Math.floor(a + 0.5f);(int)Math.floor(a + 0.5d)。
对于正数:floor是不超过整数部分,round是(int)Math.floor(a + 0.5f),四舍五入。
对于负数:floor是不超过整数部分,round是(int)Math.floor(a + 0.5f)。
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics