gazever Posted January 12, 2010 Share Posted January 12, 2010 Hi I'm getting an unexpeted result from the following, <?php echo 1481.00-1480.99; ?> output = 0.00999999999999 Does anyone understand why this is happening? Link to comment https://forums.phpfreaks.com/topic/188208-unexpected-result-from-subtraction/ Share on other sites More sharing options...
fooDigi Posted January 12, 2010 Share Posted January 12, 2010 i was confused by this also... similar issues. take a look at my post http://www.phpfreaks.com/forums/index.php/topic,278344.msg1317542.html particularly the warning on this page ... http://www.php.net/manual/en/language.types.float.php Link to comment https://forums.phpfreaks.com/topic/188208-unexpected-result-from-subtraction/#findComment-993635 Share on other sites More sharing options...
gazever Posted January 12, 2010 Author Share Posted January 12, 2010 Hi foodigi, Thanks Did you resolve your issue by rounding? Link to comment https://forums.phpfreaks.com/topic/188208-unexpected-result-from-subtraction/#findComment-993643 Share on other sites More sharing options...
gazever Posted January 12, 2010 Author Share Posted January 12, 2010 OK, fixed it using bcsub (1481.00,1480.99,2) How weird. Link to comment https://forums.phpfreaks.com/topic/188208-unexpected-result-from-subtraction/#findComment-993649 Share on other sites More sharing options...
fooDigi Posted January 12, 2010 Share Posted January 12, 2010 yeah, that worked fine for me. not to say that it's a proper solution, but i get accurate results. Link to comment https://forums.phpfreaks.com/topic/188208-unexpected-result-from-subtraction/#findComment-993650 Share on other sites More sharing options...
umarrana Posted January 12, 2010 Share Posted January 12, 2010 use bccus($number) it will work for you thanks Link to comment https://forums.phpfreaks.com/topic/188208-unexpected-result-from-subtraction/#findComment-993655 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.