Formatting doubles for output in C#

The problem is that .NET will always round a double to 15 significant decimal digits before applying your formatting, regardless of the precision requested by your format and regardless of the exact decimal value of the binary number. I’d guess that the Visual Studio debugger has its own format/display routines that directly access the internal … Read more

Double precision – decimal places

An IEEE double has 53 significant bits (that’s the value of DBL_MANT_DIG in <cfloat>). That’s approximately 15.95 decimal digits (log10(253)); the implementation sets DBL_DIG to 15, not 16, because it has to round down. So you have nearly an extra decimal digit of precision (beyond what’s implied by DBL_DIG==15) because of that. The nextafter() function … Read more