Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
ddephor44468yChecking floats for identity is not recommended. As you see, anything can happen. Check at least for an intervall.
Do you know how floats are represented in memory? If not, Google is your friend. -
I'd expect var_dump to print all the decimal numbers, but of course that's too much to ask for PHPSHIT
-
Bikonja23838yThis is weird, but to be fair, every sane person will tell you not to compare equality of floats regardless of language... I don't think this is PHPs fault, as weird as PHP can be
-
ddephor44468y@rephiscorth Read the manual, output precision of var_dump can be configured.
And you didn't show the code, just the output. Maybe it's PEBKAC.
Either way it's not PHP that's to rant about -
viking817408yAs said above, read up on double/float precision, and it will make "sense" those results
-
Root797588yAs much as I want to bash PHP for being totally freaking horrible, that behavior makes sense.
Floats are best described as close estimates.
But for a more relatable comparison, think of them the jpeg of numbers: close, but imprecise and full of artifacts. -
If you use that to say that PHP sucks, you should try adding 2.6 and 1.3 in JavaScript. Good luck!
Want more?
4.1-0.2
7.1-1.7
Math.pow(2, 55)
1<<32 -
@g-m-f haha, funny. But seriously make it clearer that it's a joke. People might actually follow that.
-
SystemZ6258yYou can blame function naming convention in PHP but floats are complicated in any language.
Related Rants
-
rephiscorth38Everyone here ranting about a fucking missing semicolon. I can't remember the last time a missing semicolon wa...
-
CodesNotHot11-Laughed at Gitlab the other day -Accidentally dropped my db today. fuck karma
-
codeclod15When you have a super annoying problem that Google has been unable to help with... But you stumble upon a link...
FUCK YOU PHP
undefined
fuck shit
fucking fuck
fuck