3 ms·
This is hardly specific to PHP. You should never compare IEEE floats using equality.
by zeroonetwothree 4y ago
This is hardly specific to PHP. You should never compare IEEE floats using equality.
- unethical_ban 4y agoIsn't it the fault of the interpreter that it shows a rounded value without being promoted to?
- IshKebab 4y agoIt is absolutely the fault of PHP. You absolutely can compare IEEE floats using equality. Often it isn't what you want but this totally should work. In this case PHP is unexpectedly rounding floats for display. ~ python3 Python 3.9.13 (main, May 24 2022, 21:28:44) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> b = 46333.48000000001 >>> b 46333.48000000001 ~ php -a Interactive shell php > $b = 46333.48000000001; php > echo $b; 46333.48