数学计算:Math,round四色五入用法
来源:互联网 发布:软件工资 编辑:程序博客网 时间:2024/06/06 19:08
在整个Math类里面可能跟大家使用最密切的就是一个round()方法:public static long round(double a)。
四舍五入代码实现;
package cn.demo;class MyMath{public static double round(double num,int scale){double result = Math.round(num * Math.pow(10, scale))/(double) Math.pow(10,scale);return result;}}public class Test {public static void main(String[] args) throws Exception {System.out.println(MyMath.round(19.3443,2));System.out.println(MyMath.round(19.5443,3));}}结果:19.34
19.544
此类操作在日后开发一定会使用到,用的时候直接拿出来使用即可。
0 0
- 数学计算:Math,round四色五入用法
- Math.ceil、Math.floor、Math.round用法
- java Math.round()用法
- Math.round用法
- java Math.round用法
- java Math.round()用法
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math.floor,Math.ceil,Math.rint,Math.round用法详解
- Math:处理数学计算的工具
- math.h里的数学计算公式
- java中的Math数学计算函数
- JAVA Math类的数学计算函数
- C#数学计算包 Math.NET
- math.h中常用数学计算公式
- AS3.0 数学函数Math的用法
- Statement中executeQuery、executeUpdate 和 execute的使用方法
- photoshop颜色混合
- Android应用中OOM问题剖析和解决方案
- 课时40|封装-封装的概念,UML类图
- android 可滑动组件互相嵌套时滑动冲突解决方案总结
- 数学计算:Math,round四色五入用法
- VC++6.0编译release版本
- Glide 加载图片之图片数据源
- 装饰者模式java
- 真机测试报The certificate used to sign "XXX" has either expired or has been revoked. An updated certifica
- Android端利用RetroFit实现多文件上传
- python遗传算法模块
- jsp的session对象的基本方法。
- Xcode真机调试出现“ is busy: Processing symbol files”