Skip to content

Money Is Not a Float: Decimals, Rounding and Cents in PHP, Python and JavaScript

Article DiscussionsSudoSecurity · · 1 min read

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.

Read the full article →

Discussion thread — share findings, corrections and follow-ups below.

0 replies

    Post a comment

    Join the discussion to share your thoughts.

    Sign in