in reply to Re^3: dependable way to test for a float
in thread dependable way to test for a float

The error was in the test and a variable being empty in the comparison. My code is working fine now. I did come across this though and wondered why:
my $var = 23123412341234.01222222; print "var=$var\n"; if(int($var) != $var){ print "is a float\n"; } else{ print "not a float\n"; }
Prints this:
var=23123412341234 is a float
The test is always working for me, so that is a good confirmation. However, I was wondering why it prints the integer before the int() function touches the variable?

Replies are listed 'Best First'.
Re^5: dependable way to test for a float
by Roy Johnson (Monsignor) on May 06, 2005 at 19:12 UTC
    It's because the number is so long it can't be represented numerically. If you use bignum;, it will behave more like you probably expect.

    Caution: Contents may have been coded under pressure.