in reply to Floats with trailing zeros as a hash key
storing these with the prices as keys, as opposed to the more natural way of doing it the other way around, seems a bit funny to me. Do you perhaps want fast lookups of the prices?
That said, there is no real need to store the two keys. Perl is smart enough to use the key in correct context. If you want to make sure the number gets printed with the trailing zero, use printf:
$ perl -e 'printf ("%0.2f", 45.2)' 45.20
This way, there's no need to store two versions of the key. Let Perl convert to the correct context if needed, and use printf if you want to pretty print.
CU
Robartes-
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Floats with trailing zeros as a hash key
by hardburn (Abbot) on May 09, 2003 at 15:40 UTC | |
by Thelonius (Priest) on May 09, 2003 at 16:21 UTC | |
by robartes (Priest) on May 09, 2003 at 16:54 UTC |