in reply to for loop with float

Whenever I use fractional numbers in my programs, I always use rounding before printing them. For example:
$i= int($i*100+.5)/100;
This makes sure you get exactly two numbers after the point. If I don't want to round the number I still add a small fractional number instead of 0.5, so that I don't get 5.99 if it really should be 6.00

Replies are listed 'Best First'.
Re^2: for loop with float
by BrowserUk (Patriarch) on Jul 25, 2008 at 00:38 UTC
      Because I would do anything to avoid printf. I've written a rounding sub in half the time I need to read the printf man page. For me printf is symbolizing the awkwardness of C programming I'm happy to have left behind

      But thanks for the TMTOWTDI ;-)