goatboy Posted December 4, 2006 Share Posted December 4, 2006 for some reason php is giving me incorrect numberslets say i do 137 / 7.25% it tells me the tax is 18.9 but it really should be something like $9i tried it with 10% and it came out correctly, Am i doing something wrong here? Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/ Share on other sites More sharing options...
AV1611 Posted December 4, 2006 Share Posted December 4, 2006 dunno. can we see the code? Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/#findComment-135100 Share on other sites More sharing options...
goatboy Posted December 4, 2006 Author Share Posted December 4, 2006 that's pretty much what it looks like$total = $subtotal / $taxso in this case$total = 137 / 7.25%then i round it off using the round function Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/#findComment-135115 Share on other sites More sharing options...
papaface Posted December 4, 2006 Share Posted December 4, 2006 [quote]but it really should be something like $9[/quote]Are you sure you are correct?Calculator even shows it as being 18.9... Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/#findComment-135118 Share on other sites More sharing options...
goatboy Posted December 4, 2006 Author Share Posted December 4, 2006 are you dividing?i just did it in the windows calulator and on this sales tax calcualtrhttp://www.convertit.com/Go/ConvertIt/Calculators/Finance/Sales_Tax_Calc.ASPit comes out to 9.93maybe i'm using a wrong formula but i'm pretty sure that's it Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/#findComment-135121 Share on other sites More sharing options...
mainewoods Posted December 4, 2006 Share Posted December 4, 2006 you get sales tax by multiplying not dividing:[code]$tax = $price * .055; //my state tax[/code] Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/#findComment-135124 Share on other sites More sharing options...
papaface Posted December 4, 2006 Share Posted December 4, 2006 You need to go:[code]$total = $subtotal * $tax /100;[/code] Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/#findComment-135126 Share on other sites More sharing options...
mainewoods Posted December 4, 2006 Share Posted December 4, 2006 [code]$taxrate = .0725; //your tax rate expressed as a decimal$total = $subtotal + ($subtotal * $taxrate);[/code] Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/#findComment-135130 Share on other sites More sharing options...
goatboy Posted December 4, 2006 Author Share Posted December 4, 2006 i got it to work with dividing by /100thanks guys!for some reason the calculator and php give different answers when i did it the original way Link to comment https://forums.phpfreaks.com/topic/29445-calculating-sales-tax/#findComment-135143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.