Perl help

Cole Tuininga colet at code-energy.com
Tue Jul 22 16:19:17 EDT 2003


Got a perl question for y'all.  I rarely have to do anything with perl,
and I'm sure perl has a good reason for behaving like the following, but
heck if I can figure it out.

The perl cookbook suggestions using sprintf for rounding floats.  This
seemingly works fine:

egon at trogdor:~$ perl -e 'print sprintf( "%.2f\n", 0.562 )'
0.56
egon at trogdor: perl -e 'print sprintf( "%.2f\n", 0.567 )'
0.57

However, I'm extremely confused by the following:

egon at trogdor:~$ perl -e 'print sprintf( "%.2f\n", 0.565 )'
0.56

Can anybody explain why this is not rounding up?  Thanks in advance...

-- 
We are Linux.  Resistance is an indication that you have missed the 
point.

Cole Tuininga
Lead Developer
Code Energy, Inc
colet at code-energy.com
PGP Key ID: 0x43E5755D





More information about the gnhlug-discuss mailing list