in reply to Re: Rounding
in thread Rounding

That causes 1.3 to be rounded to 2.0. I don't believe that's what the poster wanted.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^2: Rounding
by admiraln (Acolyte) on Sep 23, 2002 at 14:04 UTC
    No, it does not.
    I ran
    $r = 1.3; print $r,"\n"; $rounded=sprintf ("%.1f",$r+.05); print $rounded,"\n";
    and got
    perl -w round.pl 1.3 1.4
    Did you miss a 0 after the decimal? or is there some other behaviour I a missing.
      If you look a bit further,  1.4 + 0.05 prints as 1.4, not 1.5
      Argh. Sorry, was in a hurry and read to carelessly and then didn't notice the extra 0 even after tripplechecking - I didn't think anyone could be that stupid. Turns out my instinct was right, and you were too. Sorry again.

      Makeshifts last the longest.