Jump to content

Archived

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

Ninjakreborn

**solved** floating numbers question

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/

Share this post


Link to post
Share on other sites
See

[a href=\"http://www.phpfreaks.com/forums/index.php?s=&showtopic=90072&view=findpost&p=361391\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...ndpost&p=361391[/a]

Share this post


Link to post
Share on other sites

×

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.