mdannatt Posted April 3, 2009 Share Posted April 3, 2009 I am trying to divide two numbers $TAP ($10,330,000.00) by $TOTP($26,250,000.00). When echo'd I get 0.3846, but a simple check on my calculator show the real answer is 0.3935. Anyone have any ideas? the difference makes the calculation worthless. I am using XAMPP, latest release, if thats of any help. . $B = ($TAP / $TOTP); $C = $targetcontr; $D = $maxvaluecontr; $BCcalc = $B/$C; $BCDcalc = ($BCcalc * $D); $BCDcalcMIN = MIN($BCDcalc,$D); echo $TAP."<br/>"; echo $TOTP."<br/>"; echo "The adjusted procurement ratio is : ".number_format($B,4)."<br/>"; Quote Link to comment https://forums.phpfreaks.com/topic/152332-solved-incorrect-answer-when-dividing-why/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 3, 2009 Share Posted April 3, 2009 The first comma , that is encountered in each number is a stop character. So, the result is 10/26. Comma separators in numbers are there for human readability and don't belong in numbers in computers until the point where you want to output them in a human readable format. Quote Link to comment https://forums.phpfreaks.com/topic/152332-solved-incorrect-answer-when-dividing-why/#findComment-800037 Share on other sites More sharing options...
mdannatt Posted April 3, 2009 Author Share Posted April 3, 2009 arrrghhh i didnt even think of that. problem solved thanks. maybe cup of coffee is called for. Quote Link to comment https://forums.phpfreaks.com/topic/152332-solved-incorrect-answer-when-dividing-why/#findComment-800051 Share on other sites More sharing options...
Daniel0 Posted April 3, 2009 Share Posted April 3, 2009 Comma separators in numbers are there for human readability [...] Except in some languages where they are used as decimal separators. Quote Link to comment https://forums.phpfreaks.com/topic/152332-solved-incorrect-answer-when-dividing-why/#findComment-800083 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.