Money Is Not a Float: Decimals, Rounding and Cents in PHP, Python and JavaScript
- Created
- 2 Dec 2026
- Last reply
- about 5 hours ago
- Replies
- 0
- Views
- 0
- Reactions
- 0
Discussion of the blog article Money Is Not a Float: Decimals, Rounding and Cents in PHP, Python and JavaScript.
I ran the same money math through PHP 8.6, Python 3.15 and Node 26. They round 2.675 differently, bcadd('0.1', '0.2') returns 0, PHP's BcMath\Number turns a float 0.1 into 0 with only a deprecation notice, and JSON.parse quietly changes 9007199254740993 to ...992.
Discussion thread — share findings, corrections and follow-ups below.