Jump to content

**solved** floating numbers question


Ninjakreborn

Recommended Posts

What does this paragraph mean exactly in relation to php, why is this so, and what do I need to look out for, this was quoted from www.hudzilla.org.
"You should be aware that floating-point numbers are complicated beasts, and are unpredictable. The classic example is the sum "(0.1+0.7)*10" converted to an integer. You might think, "that's easy - it's 8", but PHP will report 7. The reason for this is because inherent inconsistencies in floating-point numbers mean that the value will actually be 7.9999999999999991. Usually this is not a problem, because rounding that value even to 10 decimal places gives you 8, however it does mean that you should avoid comparing floating-point numbers wherever possible"
Thanks/
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.