Jump to content

round of into two decimal places


newphpcoder
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...