floats that are not identical may have same string representation -- phpstorm should warn about those cases during an xdebug session
Given the floats:
(float) 3467.60009765625
(float) 3467.6000976562
They are different floats, as shown by their binary representation:
string(64) "0100000010101011000101110011001101000000000000000000000000000000"
string(64) "0100000010101011000101110011001100111111111111111111111110010010"
yet they have the same string representation:
var_dump((string) 3467.60009765625 . ' ' (string) 3467.6000976562);
string(31) "3467.6000976562 3467.6000976562"
This is especially confusing in xdebug sessions. I did not understand why I would “lose” the char `5` at the end:

Other numbers
(float) 3467.600097656253
(float) 3467.60009765625318323146
that share identity are always shown as one number that is in line with their string representation:

It would be very helpful for me as developer to get a warning when a float has a different string representation than the actual shown float value during an xdebug session.
https://stackoverflow.com/a/79352557/457268
---
PhpStorm 2024.3.1.1
Please sign in to leave a comment.