What to do with Java BigDecimal performance?

后端 未结 20 2528
陌清茗
陌清茗 2020-11-29 17:28

I write currency trading applications for living, so I have to work with monetary values (it\'s a shame that Java still doesn\'t have decimal float type and has nothing to s

20条回答
  •  鱼传尺愫
    2020-11-29 18:20

    easy... round your results often will eliminate double data type's error. if you are doing balance calculation, you have to also consider who will own the more/less penny caused by rounding.

    bigdeciaml calculation produces more/less penny too, consider 100/3 case.

提交回复
热议问题