phpretard Posted December 16, 2010 Share Posted December 16, 2010 Here is the number: $GrandTotal = "68.835"; $Deposit = round($GrandTotal , 2) * .5; echo $Deposit; I am looking for: 68.84 but the function doesn't seem to work right. Any help? Quote Link to comment Share on other sites More sharing options...
johnny86 Posted December 16, 2010 Share Posted December 16, 2010 You are multiplying your result with 0.5 at the end. with $Deposit = round($GrandTotal , 2); it should work right. Quote Link to comment Share on other sites More sharing options...
phpretard Posted December 16, 2010 Author Share Posted December 16, 2010 try it ... it isn't working right Quote Link to comment Share on other sites More sharing options...
johnny86 Posted December 16, 2010 Share Posted December 16, 2010 <?php $GrandTotal = "68.835"; $Deposit = round($GrandTotal , 2); echo $Deposit; // Result: 68.84 ?> Quote Link to comment Share on other sites More sharing options...
phpretard Posted December 16, 2010 Author Share Posted December 16, 2010 What could I be doing wrong then? // do some math $PZTotal = "17.97"; $FCTotal = "56.97"; $CHTotal = "65.7"; $GrandTotal = $PZTotal + $FCTotal + $CHTotal; $Deposit = round($GrandTotal , 2) * .5; [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
johnny86 Posted December 16, 2010 Share Posted December 16, 2010 // do some math $PZTotal = "17.97"; $FCTotal = "56.97"; $CHTotal = "65.7"; $GrandTotal = $PZTotal + $FCTotal + $CHTotal; $Deposit = round($GrandTotal , 2) * .5; // This is wrong remove * .5 <-- that multiplys the result with 0.5 // which meand that it is divided by 2.... //SO Correct: $Deposit = round($GrandTotal , 2); Quote Link to comment Share on other sites More sharing options...
phpretard Posted December 16, 2010 Author Share Posted December 16, 2010 // do some math $PZTotal = "17.97"; $FCTotal = "56.97"; $CHTotal = "65.7"; $GrandTotal = $PZTotal + $FCTotal + $CHTotal; $Deposit = round($GrandTotal , 2) * .5; // This is wrong remove * .5 <-- that multiplys the result with 0.5 // which meand that it is divided by 2.... //SO Correct: $Deposit = round($GrandTotal , 2); The deposit is half of the $GrandTotal. Where should I do that math? Quote Link to comment Share on other sites More sharing options...
phpretard Posted December 16, 2010 Author Share Posted December 16, 2010 $Half = $GrandTotal * .5; $Deposit = round($Half, 2); This works. Thank you all! Quote Link to comment Share on other sites More sharing options...
idiotstrike Posted December 16, 2010 Share Posted December 16, 2010 You need to divide it first and then round it. $Deposit = $GrandTotal * 0.5; $Deposit = round($Deposit, 2); Quote Link to comment 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.