"Jack Klein" <> wrote...
> On Mon, 11 Oct 2004 11:40:15 +0200, "Gernot Frisch" <>
> wrote in comp.lang.c++:
>
>> Hi,
>>
>>
>> I want to represent a double in char* as accurate as possible, but as
>> short as possible:
>>
>> double char*
>> 10000 1E5
>> 1000.00123 1000.00123
>> ...
>>
>> How can I archive this?
>> %.10f prints too much, and %.10g is too inaccurate.
>
> sprintf() with "%.20f" into a large enough character array buffer.
> Trim trailing zeros. Do what you need to do with the result.
So, how well is it going to represent 1.000000000009e-22? Just curious,
I guess...
Victor
|