newphpcoder Posted April 18, 2012 Share Posted April 18, 2012 Hi..I encountered problem in rounding of numbers into two decimal places.here is my sample code: if($W4_STATUS == 1 AND $DEPENDENTS == 0 AND $TotEarn >= 7917 AND $TotEarn <= 12500) { $TAX = ($TotEarn - 7917); $TAX = (937.50 + ($TAX * .25)); $TAX = number_format($TAX, 2, '.', '');} for example from this: $TAX = ($TotEarn - 7917); $TAX = (937.50 + ($TAX * .25)); the output is: 1417.615using this: $TAX = number_format($TAX, 2, '.', ''); the output was : 1417.61but it should be : 1417.62Thank you Link to comment Share on other sites More sharing options...
Ingolme Posted April 18, 2012 Share Posted April 18, 2012 Use PHP's round() function: $TAX = round($TAX, 2); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.