Floating Point Math

https://0.30000000000000004.com/

Floating Point Math

This article provides a comprehensive overview of floating-point arithmetic inaccuracies, specifically demonstrating why 0.1 + 0.2 often does not equal 0.3, across numerous programming languages and systems. It offers code examples for each language, illustrating the issue and discussing potential solutions such as using decimal types or rational numbers to maintain precision.

Note

making the unintuitive intuitive is a worthwhile effort

Published

2012

Summary

This article provides a comprehensive overview of floating-point arithmetic inaccuracies, specifically demonstrating why 0.1 + 0.2 often does not equal 0.3, across numerous programming languages and systems. It offers code examples for each language, illustrating the issue and discussing potential solutions such as using decimal types or rational numbers to maintain precision.