formatting floating point

Saaa empty at needmail.com
Mon Jul 13 17:47:39 PDT 2009


>>> You'd just have to convert each element of the
>>> array separately.
>>
>> I found the formatting options, they are in std.format..
>> (I was apparently searching for the 'g' option.. )
>>
>> this seems to work (using std2.string.format)
>>
>> double[] d1;
>> d1=[double.max,double.min];
>> char[] c;
>> c=format( "%.100g",d1); //100 is enough for reals I think?
>> writefln(c);
>> //[1.7976931348623157079e+308,2.2250738585072013832e-308]
> double.dig, real.dig gives you the number of meaningful decimal digits.
Ah, I see, thanks.
But choosing an insane big number of precision in combination with g seems 
to work perfectly already.
Although there probably is a better formatting option, I hope.




More information about the Digitalmars-d-learn mailing list