Max value can stored in Java float with two digit precision (2 digit accuracy)?

前端 未结 4 942
情深已故
情深已故 2021-01-27 17:55

How I could find max two decimal precision vale that can be stored in float ?

From my understanding, In 32 bit float we have 24(23+1) for storing the number excluding ex

4条回答
  •  执念已碎
    2021-01-27 18:26

    If you simply want to store numbers with exactly two decimal digits after the point, store 100 times the number as an integer (or long, depending on how big your numbers get), and add the point (or comma) on formatting (remove on parsing).

    This is much easier to control.

提交回复
热议问题