博客
关于我
Java中Math.round()方法的取整规则
阅读量:688 次
发布时间:2019-03-17

本文共 409 字,大约阅读时间需要 1 分钟。

just一句话:取最近的正数,当有两个最近的正数时,就取最大的那个!

举个例子:

public class Test {    public static void main(String[] args) {        System.out.println(Math.round(10.6));//11        System.out.println(Math.round(-10.6));//-11        System.out.println(Math.round(9.5));//10        System.out.println(Math.round(-9.5));//-9        System.out.println(Math.round(10.49));//10        System.out.println(Math.round(-10.49));//-10    }}

 

转载地址:http://jfvhz.baihongyu.com/

你可能感兴趣的文章
Nacos2.X源码分析:服务注册、服务发现流程
查看>>
NacosClient客户端搭建,微服务注册进nacos
查看>>
Nacos中使用ribbon
查看>>
Nacos使用OpenFeign
查看>>
Nacos使用Ribbon
查看>>
Nacos做注册中心使用
查看>>
Nacos做配置中心使用
查看>>
Nacos入门过程的坑--获取不到配置的值
查看>>
Nacos原理
查看>>
Nacos发布0.5.0版本,轻松玩转动态 DNS 服务
查看>>
Nacos启动异常
查看>>
Nacos命名空间配置_每个人用各自自己的命名空间---SpringCloud Alibaba_若依微服务框架改造---工作笔记001
查看>>
Nacos和Zookeeper对比
查看>>
Nacos在双击startup.cmd启动时提示:Unable to start embedded Tomcat
查看>>
Nacos基础版 从入门到精通
查看>>