1 Unstar Star 1 Fork 0

625 / JAVA精确四则运算工具

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

使用方式如下


// 0原生计算
System.out.println("原生:" + (0.1 + 0.2));
// 1.链式操作
double v1 = CalcUtils.init(0).add(0.1).add(0.2).doubleValue();
System.out.println("链式:" + v1);
// 2.直接操作
double v2 = CalcUtils.add(0.1, 0.2).doubleValue();
System.out.println("直接:" + v2);
// 3.混合运算,支持任何类型
float v3 = CalcUtils.add(0.3, 0.5f).mul(0.5d).div(2L).sub(2).add((short) 2).floatValue();
System.out.println("混合运算:" + v3);
// 4.小数位默认2位
double v4 = CalcUtils.div(2, 3).doubleValue();
System.out.println("小数默认2位:" + v4);
// 5.小数位可调整调整
double v5 = CalcUtils.div(2, 3).doubleValue(6);
System.out.println("调整小数位:" + v5);

结果

原生:           0.30000000000000004
链式:           0.3
直接:           0.3
混合运算:       0.2
小数默认2位:    0.67
调整小数位:     0.666667

Comments ( 0 )

Sign in for post a comment

About

JAVA精确计算,加减乘除的工具。 spread retract
Java
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
Java
1
https://git.oschina.net/stupid1t/calc.git
git@git.oschina.net:stupid1t/calc.git
stupid1t
calc
JAVA精确四则运算工具
master

Search

132457 8cb2edc1 1899542 131848 70c8d3a4 1899542