in reply to testing for numerical equality

The problem is that the rounding can give you the same number for two different "large" numbers, so you can't always retrieve the original number from a short one. If you don't care about losing the original number, you can use a hash:
use strict; use warnings; my @nums = qw( 0.0989999999999 0.0981111111111 0.6799999999999 0.0859999999999 0.0239999999999 0.0239999999993 ); my @found = qw( 0.099 0.086 0.024 ); # create a hash, with the rounded number as the key, and # the original number as the value # Note that it only store a single value, so only the last # original number is stored. my %short_nums = map { sprintf("%.3f", $_) => $_ } @nums; foreach my $short (@found) { if(exists $short_nums{$short}) { print "Long num for $short = ", $short_nums{$short}, "\n"; } else { print "No matching long num for $short ...\n"; } }
output:
Long num for 0.099 = 0.0989999999999 Long num for 0.086 = 0.0859999999999 Long num for 0.024 = 0.0239999999993
... and if you do care about the lose of the original number, then there is no solution :)