Printing a floats in maximum precision
    Basile B. via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Tue Jan 17 19:54:33 PST 2017
    
    
  
On Wednesday, 18 January 2017 at 00:09:42 UTC, Nordlöw wrote:
> What's the easiest way to print a double in maximum precision?
%.6g for floats and %.17g for doubles. This is for example what's 
used on std.json to get a perfect conversion from string to 
value. the number is the maximum number of digits in the 
fractional part.
6 and 17 are rounded, real values can be found  here 
(https://en.wikipedia.org/wiki/Floating_point#Internal_representation)
see also:
http://stackoverflow.com/questions/16839658/printf-width-specifier-to-maintain-precision-of-floating-point-value/21162120#21162120
and this
https://github.com/dlang/phobos/pull/4343#issuecomment-220810593
    
    
More information about the Digitalmars-d-learn
mailing list