On Mon, 10 Oct 2005 08:46:34 GMT, Owen Jacobson
<angrybaldguy@google-email-service.example.com> wrote:
[color=blue]
>On Mon, 10 Oct 2005 10:36:33 +0200, Bob Hairgrove wrote:
>[color=green]
>> On Mon, 10 Oct 2005 01:17:34 -0700, "Jonny" <jonyy@aol.com> wrote:
>>[color=darkred]
>>>If you run the following code , you will get 1.12346e07 as the output. What
>>>do I need to do if you want all the significant digits output, like
>>>1.123456789e07?[/color][/color]
>
>(Snip)
>[color=green][color=darkred]
>>> long a = 1123456789;
>>> float p = 100;
>>> double d = (double) (a / p) ;[/color][/color]
>
>(Snip)
>[color=green]
>> Look for ios_base::precision, width, etc. in the STL documentation.[/color]
>
>The other problem is the intermediate converstion to float during the
>evaluation of (a / p), prior to conversion to double... I'm not
>comfortable enough with FP math to say for certain that that'll lose
>digits in this case, but it may well.
>
>-O[/color]
Good catch ... I overlooked the fact that p is float, not double.
--
Bob Hairgrove
NoSpamPlease@Home.com