Double precision after decimal point

At lunchtime, we began to discuss the accuracy of type values double.

My colleague believes that he always has 15 places after the decimal point.

In my opinion, this cannot be said because the IEEE 754 makes no assumptions about this, and it depends on where the first 1is in binary representation. (i.e. the size of the number to the decimal point too)

How to make a more qualified statement?

+6
source share
4 answers

As the C # link indicates , the precision is 15 to 16 digits (depending on decimal values) before or after the decimal point.

, , .

:

  • 12345678.1234567D// .
  • 1234567.12345678D// .

: http://ideone.com/eXvz3

, double .

+3

. double 53 . 16 , , double, , .

, , - ; double .

, , 4503599627370496.0, 4503599627370497.0.

+3

# IEEE 754 53- p ( ) 11- e, -1022 1023.

p * 2^e

, . , ; , , .

What every computer scientist needs to know about floating point arithmetic is probably the most widely known publication on this subject.

0
source

Since this is the only SO question I could find on this topic, I would like to add jorgebg answer .

According to this , the accuracy is actually 15-17 digits. An example of a double with 17 digits of accuracy would be 0.92107099070578813 (don't ask me how I got this number: P)

0
source

All Articles