newphpcoder Posted April 18, 2012 Report 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 Report 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
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now