note 129905 added to function.bccomp
| From: | mm@mobelt.com | Date: | Sun, 08 Dec 2024 09:15:55 +0000 |
| Subject: | note 129905 added to function.bccomp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221710@lists.php.net to get a copy of this message | ||
If you want to compare 2 decimals for equality, bccomp does not works as expected:
bccomp("1.000000000000000","0.999999999999999",2)
returns 1
Instead, use
bcsub("1.000000000000000","0.999999999999999",2) == 0
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2a0c:5a81:205:f600:8397:79d7:aab6:ccfb)
----
Manual Page -- https://php.net/manual/en/function.bccomp.php
Edit -- https://main.php.net/note/edit/129905
Del: integrated -- https://main.php.net/note/delete/129905/integrated
Del: useless -- https://main.php.net/note/delete/129905/useless
Del: bad code -- https://main.php.net/note/delete/129905/bad+code
Del: spam -- https://main.php.net/note/delete/129905/spam
Del: non-english -- https://main.php.net/note/delete/129905/non-english
Del: in docs -- https://main.php.net/note/delete/129905/in+docs
Del: other reasons-- https://main.php.net/note/delete/129905
Reject -- https://main.php.net/note/reject/129905
Search -- https://main.php.net/manage/user-notes.php