2

Possible Duplicate:
What is the meaning of numeric_limits<double>::digits10

According to my understanding (about what I rode over internet) It seems that std::numeric_limits<double>::digits10 (which for double is equal to 15) represent the number of digits a double can handle, for instance 1.23456789012345 but not 1.234567890123456

On the other side Double-precision floating-point format range will go until 1.8*10^+308, which seems to represent a number wich not hold only on 15 digits...

Where is the incoherence ?

Community
  • 1
  • 1
Guillaume Paris
  • 9,916
  • 14
  • 65
  • 136

3 Answers3

4

... std::numeric_limits<double>::digits10 (which for double is equal to 15) represent the number of digits a double can handle...

More precisely it's the number of significand digits it can store without loss of precision.

Example in Python:

1e15 == 1e15 + 1
False 

1e16 == 1e16 + 1
True # loss of precision
Maxim Egorushkin
  • 125,859
  • 15
  • 164
  • 254
1

std::numeric_limits::digits10: Number of digits (in decimal base) that can be represented without change.

Denis Ermolin
  • 5,410
  • 6
  • 26
  • 43
1

The one is significant digits. The other is the range of numbers representable. So, you can have:

1.23456789012345*10^308

but not

1.234567890123456*10^308

which shows both significant digits 15 and the range 10^308, which can be represented.

Olaf Dietsche
  • 69,448
  • 7
  • 95
  • 188