my $fmt = '%.02f'; if ( sprintf($fmt, $num1) eq sprintf($fmt, $num2) ) { print "they're the same, to two decimal places\n"; } #### my $diff = 0.005; if ( abs($num1-$num2) < $diff ) { print "they're close enough\n"; }