in reply to Re^4: [s]printf %d oddity
in thread [s]printf %d oddity

Sure it would be nice if this would always work, but that's why it's recommended to always use sprintf() to round before comparing if you're working with floating point numbers. You won't know when it will break otherwise. Keep in mind that perl uses the underlying C compiler's native float.

By the way, how do you know that 8.78 isn a repeating finite number in binary?

On my machine:

#!/usr/local/bin/perl -w use strict; my $x = pack("F",8.78); print(unpack("B*",$x)); __OUTPUT__ 1000111111000010111101010010100001011100100011110010000101000000

Now, if I only knew which part was what :-)

updated: s/8.98/8.78/