What to do with Java BigDecimal performance?

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

    1/b is not exactly representable with BigDecimal either. See the API docs to work out how the result is rounded.

    It shouldn't be too difficult to write your own fixed decimal class based around a long field or two. I don't know any appropriate off the shelf libraries.

提交回复
热议问题