宇筱博客

  • 解决办法
  • 学无止境
  • 记录时光
  • 百宝箱
宇筱博客
点滴记忆,汇聚成海。
  1. 首页
  2. 解决办法
  3. 正文

BigDecimal加减乘除绝对值计算

2022年10月17日 837点热度 0人点赞 0条评论
public static void main(String[] args) throws ParseException {
BigDecimal num1 = new BigDecimal("0.6");
BigDecimal num2 = new BigDecimal("0.3");
BigDecimal num3 = new BigDecimal("-0.1");
//加法
System.out.println("和:" + num1.add(num2));
//减法
System.out.println("差:" + num1.subtract(num2));
//乘法
System.out.println("积:" + num1.multiply(num2));
//除法
System.out.println("商:" + num1.divide(num2));
//绝对值
System.out.println("绝对值:" + num3.abs());
}

执行结果:

原文连接:点击进入

标签: 暂无
最后更新:2022年11月1日

小渔民

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2025 宇筱博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

豫ICP备15017825号-2