Non-terminating decimal expansion; no exact representable decimal result

翻译:无法终止小数点扩展; 没有确切的可表示的小数结果

出现的情形:

BigDecimal num1 = new BigDecimal("10");

BigDecimal num2 = new BigDecimal("3");

BigDecimal num3 = num1.divide(num2);

出现了无线循环小数。

可以使用devide重载方法BigDecimal.divide(BigDecimal divisor, int scale, RoundingMode roundingMode) ;

RoundingMode源码解析:

public enum RoundingMode {/*** Rounding mode to round away from zero.  Always increments the* digit prior to a non-zero discarded fraction.  Note that this* rounding mode never decreases the magnitude of the calculated* value.** 远离0的舍入模式。总是在非零的小数前增加数值。请注意,该舍入模式不会减小计算值的大小。**<p>Example:*<table border>*<tr valign=top><th>Input Number</th>*    <th>Input rounded to one digit<br> with {@code UP} rounding*<tr align=right><td>5.5</td>  <td>6</td>*<tr align=right><td>2.5</td>  <td>3</t

Non-terminating decimal expansion; no exact representable decimal result异常相关推荐

  1. java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal res

    转载自:https://www.cnblogs.com/LeoBoy/p/5897754.html 今天在写一个JAVA程序的时候出现了异常:java.lang.ArithmeticException ...

  2. Non-terminating decimal expansion; no exact representable decimal result。

    使用 Bigdecimal 做除法,除不尽时 JDK1.7 会报错. Non-terminating decimal expansion; no exact representable decimal ...

  3. Non-terminating decimal expansion; no exact representable decimal res

    在使用BigDecimal做出发运算时,如果没有指定小数点位数,在除不尽的时候,就会出现java.lang.ArithmeticException: Non-terminating decimal e ...

  4. Java中BigDecimal异常Non-terminating decimal expansion; no exact representable decimal result

    异常描述: Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal ex ...

  5. Non-terminating decimal expansion; no exact representable decimal result

    Non-terminating decimal expansion; no exact representable decimal result 这种异常是由于用BIgDecimal做divide(除 ...

  6. 错误描述:Non-terminating decimal expansion; no exact representable decimal result.

    错误描述:Non-terminating decimal expansion; no exact representable decimal result. 在做电子发票部分要计算计税额,基本是Big ...

  7. 解决:java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 报错如下: java.lang.ArithmeticException: Non-terminati ...

  8. java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal

    今天实际开发中碰到这个报错: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representa ...

  9. Non-terminating decimal expansion; no exact representable decimal result. 的恩恩怨怨

    问题描述 在工作中,使用到BigDecimal类进行除法运算,结果系统在运行的过程中,发生了如下错误信息: Exception in thread "main" java.lang ...

最新文章

  1. 九度oj 题目1252:回文子串
  2. C#操作符??和?:
  3. 【android】 浏览文件,如浏览sd卡下的图片文件
  4. C运行库和C语言函数库/Microsoft C运行库
  5. 如何启用计算机超级账户,Windows7启用超级管理员账户的方法
  6. C#算法设计排序篇之07-希尔排序(附带动画演示程序)
  7. 经验:Library Cache Lock之异常分析-云和恩墨技术通讯精选
  8. 零基础学python图文版-教到你会为止的Python入门课程即将开班
  9. 对Movielens数据集进行评分预测
  10. Excel表格的35招必学秘技
  11. 归并算法 merge
  12. 基于树莓派SHT20温湿度采样
  13. 免费站群系统cm-SEO需要多长时间?
  14. 万字综述:如何打造自动驾驶的数据闭环?
  15. 语法长难句——并列句
  16. GOOGLE卫星地图
  17. [nginx]SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
  18. Tomcat调优指南
  19. python-笔记(四)函数
  20. Kubernetes 1.25 发布!博云带你玩转新特性

热门文章

  1. Process的waitFor死锁问题及解决办法
  2. iPhone取消Siri语音关机是好是坏
  3. html怎么导入miniui,MiniUI小结
  4. Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource
  5. 【征集需求】准备开发一个针对淘宝卖家的excel模板,实现在Excel上做帐
  6. ♥♥C站最全NCRE四级数据库总结(时刻更新,建议收藏!)
  7. 空指针异常(Null Pointer Exception)如何避免!
  8. 006--Keil使用--出现declared implicitly
  9. 数字信号处理三:离散时间LTI系统的z域分析
  10. 【PPT】Vue.js 团队成员蒋豪群:Vue 高效开发之路