Foemmel's Conundrum

Foemmel's Conundrum

Matt Foemmel's Conundrum refers to a logical rounding error that occurs with monetary calculations on computer systems that use floating-point numbers to store currency values.

Allocate the whole sum of an amount to exactly two accounts: 70% to one account and 30% to another. With a whole amount of $0.05 USD it would be impossible to arrive at correct assignments. [1]

The solution is to implement an explicit allocation method and include it as part of an object that overrides arithmetic functions on money.

References

Patterns of Enterprise Application Architecture (489), Martin Fowler ISBN: 978-0-321-12742-0


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”