http://qs1969.pair.com?node_id=257028


in reply to Floats with trailing zeros as a hash key

I am going to guess that my suggestion (below) is too big a rewrite for the code you're working on, but let me make it anyway:

Store prices as integer cents.

There are several reasons that C programs usually store prices as integer amounts of pennies, and then convert to dollars at the last minute:

This might be one of those cases for you, too. 4520 pennies will never get rounded to 452 pennies, but 45.20 dollars (or euros) will get rounded to 45.2 by internal number-to-string conversions.

Just my $0.02 er, 2¢