What range of numbers can be represented in a 16-, 32- and 64-bit IEEE-754 systems?

前端 未结 7 1434
天涯浪人
天涯浪人 2020-11-22 12:20

I know a little bit about how floating-point numbers are represented, but not enough, I\'m afraid.

The general question is:

For a given preci

相关标签:
7条回答
  • 2020-11-22 13:01

    It took me quite a while to figure out that when using doubles in Java, I wasn't losing significant precision in calculations. floating point actually has a very good ability to represent numbers to quite reasonable precision. The precision I was losing was immediately upon converting decimal numbers typed by users to the binary floating point representation that is natively supported. I've recently started converting all my numbers to BigDecimal. BigDecimal is much more work to deal with in the code than floats or doubles, since it's not one of the primitive types. But on the other hand, I'll be able to exactly represent the numbers that users type in.

    0 讨论(0)
提交回复
热议问题