Re: sprintf does not round floating point numbers
- From: "Alexander Grigoriev" <alegr@xxxxxxxxxxxxx>
- Date: Fri, 20 Jan 2006 07:57:20 -0800
In the format string, specify exact number of digits you want after the
floating point (less that full precision). Then the last 1 will be
discarded.
"David Liebtag" <DavidLiebtag@xxxxxxxxxxxxx> wrote in message
news:%237r1DcdHGHA.2064@xxxxxxxxxxxxxxxxxxxxxxx
> Folks,
>
> I transcribed the sprintf output incorrectly. We do indeed get:
>
> +1.0000000000000001E-1 with Visual Studio
> +1.0000000000000000E-1 with the old compiler
>
> I fully understand that the least significant digit is not reliable, and
> that our users should not depend on it. Actually, our product uses the
> sprintf result as an intermediate value and strips trailing zeros before
> returning the value to the user. Since the VS result does not have
> trailing zeros, our users are getting different results than they are used
> to. We are trying to determine whether we should ignore the last digit,
> use a different control string, or return the full sprinf result.
>
> Victor Bazarov hinted at the information I'm searching for when he
> mentioned the C standard.
>
> Does the C standard specify which of the two values sprintf should
> produce?
>
> Thank you for your help and sorry for the confusion I caused by my
> incorrect transcription.
>
> David Liebtag
>
>
.
- References:
- sprintf does not round floating point numbers
- From: David Liebtag
- Re: sprintf does not round floating point numbers
- From: David Liebtag
- sprintf does not round floating point numbers
- Prev by Date: Re: why the leaking? please advise
- Next by Date: Re: Linking problem
- Previous by thread: Re: sprintf does not round floating point numbers
- Next by thread: Re: sprintf does not round floating point numbers
- Index(es):
Relevant Pages
|