Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Decimal precision
Message
De
23/05/2012 09:32:08
 
 
À
23/05/2012 09:12:48
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01544101
Message ID:
01544137
Vues:
26
>>That depends on the context. If the context is currency, you will mostly only consider two decimals
>>
>>In your tax problem
>>
>>
>>base for federal tax = 500.00
>>round(500.00 * .05, 2) = 25.00 && federal tax
>>
>>base for  provincial tax = 500.00 + 25.00 = 525.00
>>
>>round( ( 500.00 + 25.00) * 9.5 / 100, 2) = 49.88 && provincial tax
>>
>>Total = 500.00 + 25.00 + 49.88 = 574.88
>>
>>
>>So, if you want to reverse the process, you have to apply the steps backwards - one at a time - do not combine them - this is no algebra
>>After each division you have to round to 2 decimals
>>
>>
>>Total = 574.88
>>(1) 
>>Base for provincial tax = round( 574.88 / 1.095, 2) = 525.00
>>
>>provincial tax = 574.88 -  525.00 = 49.88
>>
>>(2) 
>>base for federal tax = Base for provincial tax / 1.05
>>base for federal tax = round( 525.00 / 1.05, 2)  = 500.00
>>federal tax = 525.00 - 500.00 = 25.00
>>
>>
>>
>>iow, you need two decimals since the taxes were calculated with two decimals
>>
>>You apply the steps backwards
>> - dividing and rounding to 2 decimals to obtain the base
>> - subtracting to obtain the tax ( do not use a division here )
>
>Thanks, this sums it all assuming you have the original amount. In the other thread, where I am looking for the formula, we do not have the original amount. We only have the total tax amount and we need to collect each tax from that total tax amount.


I don't think that is possible - due to rounding scenarios

Take this for example
Provincial tax on  $1.74 is round(1.74 * .095, 2) or $0.17

What amount is the base of $0.17 tax ?

round($.017 / .095,2)  = $1.79  (see how this compares to the original $1.74)
iow, you need the Total including all taxes, and knowing the two percentages and the order in which they were applied, you work your way back
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform