in reply to Force currency view
If this is any part of an actual system, and not just a programming assignment, you will be well served to stay away from floating point numbers when adding currencies. See What Every Scientist Should Know About Floating-Point Arithmetic or search the monastery for floating point accuracy.
One thing that you can do is do your calculations in cents, and only do the conversion for display purposes ($cents / 100).
Update: Update to more long-lived link. Thanks to HalNineThousand below.
--MidLifeXis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Force currency view
by HalNineThousand (Beadle) on Feb 08, 2011 at 19:15 UTC | |
|
Re^2: Force currency view
by bibliophile (Prior) on Feb 08, 2011 at 14:45 UTC | |
|
Re^2: Force currency view
by locked_user sundialsvc4 (Abbot) on Feb 08, 2011 at 19:13 UTC |