[Israel.pm] Rounding numbers to the nearest quarter???

Yuval Kogman lists at woobling.org
Thu May 6 07:07:26 PDT 2004

On Thu, May 06, 2004 at 16:42:15 +0300, Jason Elbaum wrote:

> All right Yuval, mind explaining what's wrong with it?

More room for error, when there's no need, and one more character for
the same effect (I was going to say "and much longer to type", but then
It turns out it's not that much ;-)

int($x*100+0.5)/100;	int ( ( $x * 100 ) + 0.5 ) / 100;
sprintf("%.2f",$x);		sprintf("%.2f", $x);

 ()  Yuval Kogman <nothingmuch at woobling.org> 0xEBD27418  perl hacker &
 /\  kung foo master: *shu*rik*en*sh*u*rik*en*s*hur*i*ke*n*: neeyah!!!!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20040506/a6475b8a/attachment.pgp 

More information about the Perl mailing list