-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with casting into (int) or intval() #8028
Comments
Floating point values have a limited precision. Hence a value might If you would like to know more about "floats" and what IEEE Thank you for your interest in PHP. |
So this one also acts "by design"? |
@VILQ Yes. $x = 0.1 + 0.2;
var_dump($x);
echo $x. "\n";
ini_set('precision', -1);
echo $x, "\n";
|
So you really didn't notice the difference between: |
The precision INI setting's default is changed as of PHP 8.0.0. |
Description
The following code:
Resulted in this output:
But I expected this output instead:
The result is consistent when we change '34.84' to e.g. '34.85', '34.86' or '34.83'.
Eval link: https://3v4l.org/geEpE
When $b = intval($a) the result is the same.
PHP Version
8.0.22
Operating System
No response
The text was updated successfully, but these errors were encountered: