Link to home
Start Free TrialLog in
Avatar of gil_mo
gil_mo

asked on

sprintf precision bug?

Using MSDEV 6.0 environment:

Consider the following:

sprintf( Buf,"%0.1f",0.85 ) ;
sprintf( Buf,"%0.1f",0.75 ) ;

In both cases, Buf is set to: "0.8".
Is this a bug? Can anyone detect the origination of this bug?
Avatar of gil_mo
gil_mo

ASKER

Edited text of question.
ASKER CERTIFIED SOLUTION
Avatar of Slarti
Slarti

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
Even if the values were exact, rounding to even is the preferred mode for decimal numbers anyway, so you just happened to get the right answer depite the inaccuracy.