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
https://forums.phpfreaks.com/topic/7649-solved-floating-numbers-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.