To calculate dollars "accurately" with 2 decimal places, you need

to calculate right from the beginning in cents as integers!

So just calculate with integers in the desired accuracy and shift the decimal point afterwards²!

And now imagine you're an alien with 3 fingers ^{4} and you have only computers that calculate in decimal fractions¹... wouldn't this annoy you, too?

Cheers Rolf

Footnotes:

- (¹) I have a faint memory of processors with special modes allowing to calculate in decimal system... was it 6502 or 68000? Must be the latter ...
... indeed

*"Although the 68000 has a 16-bit data bus... internally it can operate on ... 4-bit binary coded decimal (BCD), ..."* - (²) The shift must be a string operation. Dividing by 100 reintroduces the problem with floats!
- (³) added some images like of human reengineering. (... another - though bloody -rule of thumb ;-)
- (
^{4}) in a ternary system 0.1 exactly represents 1/3 in decimal.

*In reply to* **Humans have too many fingers**
*by* **LanX**
*in thread* **perl floating number addition**
*by* **adismaug**

- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr

For: |
Use: |
||

& | & | ||

< | < | ||

> | > | ||

[ | [ | ||

] | ] |