What to do with Java BigDecimal performance?

后端 未结 20 2523
陌清茗
陌清茗 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:09

    On a 64bit JVM creating your BigDecimal as below makes it about 5x faster:

    BigDecimal bd = new BigDecimal(Double.toString(d), MathContext.DECIMAL64);
    

提交回复
热议问题