71
Comments
  • 0
    I'm sorry but I actually loled here
  • 12
    Checking 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.
  • 3
    I'd expect var_dump to print all the decimal numbers, but of course that's too much to ask for PHPSHIT
  • 4
    Then why use it?
  • 1
    I can't replicate the problem
  • 21
    This 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
  • 3
    @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
  • 4
    As said above, read up on double/float precision, and it will make "sense" those results
  • 17
    As 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.
  • 4
    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
  • 6
    @g-m-f haha, funny. But seriously make it clearer that it's a joke. People might actually follow that.
  • 1
    PHP is the
    Best language ever.
  • 1
    @Ashkin that is an amazing comparison, jpeg of numbers :D
  • 0
    You can blame function naming convention in PHP but floats are complicated in any language.
Add Comment