in reply to How to determine whether a number has a decimal component?
I would compare to int because it says what I mean, and it will work in some strange cases where the regexp won't.
use Test::More 'tests' => 2; my $x = 1 - 2**-52; ok( $x != int $x, 'int method works' ); # this test fails ok( $x =~ /\./, 'RegExp method works' );
Basically, don't treat your numbers as strings if you don't have to.
|
|---|