in reply to comparing two amounts of money.
$a = 12.02; $b = 24.32; $a = int( $a* 100 ); $b = int( $b * 100 ); print ($a + $b)/100, "\n";
Having done real-time currency conversions for e-commerce sites I can say there at least two things to consider when working with monetary values:
1. the above normalization works fine for most major monetary systems but would fail for others (correct me if I'm recalling wrong or things have changed but some middle east monetary systems are one-thousandths based not one-hundredths)
2. normalizing to integers will break big time for real large monetary values (I wouldn't like to figure out the US national debt with this system - nor the burn rate of a lot of dot-coms).
Those being said, if your monetary domain is straight-forward your life will be easier if you convert to integers.
-derby
|
|---|