[PHP-NOTES] note 130511 added to language.types.float

[email protected] ("[email protected]") Tue, 14 Oct 2025 12:27:07 +0000
Newsgroups php.notes
Message-ID <[email protected]>
Since actual values can vary slightly, $epsilon may not be set according to your configuration. You can replace $epsilon with PHP_FLOAT_EPSILON. There is also, in my opinion, a more elegant method for checking float equality:

<?php
// bccomp will returns 0 for equality, 1 if $value1 is greater and -1 otherwise
if (bccomp($value1, $value2) == 0) {
  // equals
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 82.67.118.175)
----
Manual Page -- https://php.net/manual/en/language.types.float.php
Edit        -- https://main.php.net/note/edit/130511
Del: integrated  -- https://main.php.net/note/delete/130511/integrated
Del: useless     -- https://main.php.net/note/delete/130511/useless
Del: bad code    -- https://main.php.net/note/delete/130511/bad+code
Del: spam        -- https://main.php.net/note/delete/130511/spam
Del: non-english -- https://main.php.net/note/delete/130511/non-english
Del: in docs     -- https://main.php.net/note/delete/130511/in+docs
Del: other reasons-- https://main.php.net/note/delete/130511
Reject      -- https://main.php.net/note/reject/130511
Search      -- https://main.php.net/manage/user-notes.php