in reply to Re: Re: Floats with trailing zeros as a hash key
in thread Floats with trailing zeros as a hash key
You basically force the numbers in a certain format (rounded to 4 decimals and zero padded in this case). That way, you are guaranteed that 45.20 and 45.2 will end up as 45.2000 and thus in the same hash entry.my $key = sprintf("%0.4f", $price); $items{$key}=$item;
Now remind me again why you want to put the prices in the keys? What happens if you have two items with equal prices?
CU
Robartes-
|
|---|