in reply to sprintf and decimals

Is there any environment where you get 2.68? gcc should give you 2.67, too.

Replies are listed 'Best First'.
Re^2: sprintf and decimals
by swampyankee (Parson) on Nov 15, 2006 at 18:56 UTC

    Is there any environment where you get 2.68?

    If there is, it's wrong.

    gcc should give you 2.67, too.

    Yes, it should. So should C, C++, COBOL, Pascal, Fortran (it does), Python, Ruby, Haskell, Erlang, VB, C#, etc.…. The rounding rules are not just custom; there are actually international standards.

    emc

    At that time [1909] the chief engineer was almost always the chief test pilot as well. That had the fortunate result of eliminating poor engineering early in aviation.

    —Igor Sikorsky, reported in AOPA Pilot magazine February 2003.