Because Perl definitely isn't dead.
Random header image... Refresh for more!

POSIX said what???

POSIX is a Perl module that gives you access to the IEEE 1003.1 standard functions. It’s all implemented in C and so it’s nice and fast. Installed virtually everywhere and provided by the system.

All in all it’s lovely for it’s thing, until I saw this blog post. Obviously this is a Ruby problem, well oops no as I said POSIX provides some nice functionality including functions for rounding floating point numbers. So in essence both Ruby and Perl are using the same system calls to do the rounding.

So I fired up a console and tried the following:

> perl -MPOSIX -e 'print ceil(69.54 * 100), "\n"; '
> 6955

Sorry… you what???? 69.54 x 100 = 6954, so ceil(6954) = 6955…. I think not. So ceil(6954) is not equal to ceil(69.54 * 100). Try it on your OS and see what happens.

1 comment

1 Mark { 10.24.08 at 4:28 pm }

Same thing in python:

>> import math
>>> math.ceil(69.54 * 100)
6955.0

Leave a Comment