formatting floating point

Don nospam at nospam.com
Mon Jul 13 04:33:44 PDT 2009


Saaa wrote:
>> Ohh, I see.  Your initial question was really vague, now that I see
>> what you were asking.
> sorry
>> 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.


More information about the Digitalmars-d-learn mailing list