Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Decimal precision
Message
From
23/05/2012 11:43:25
 
 
To
23/05/2012 11:27:23
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01544101
Message ID:
01544153
Views:
25
>I'ts not a loop, it just ends without finding a solution because a total tax of $500.00 does not exist
>
>What happens is that fedTax + provTax is 499.99 at one moment and the next iteration it is 500.01
>
>So I have added an extra if: fedTax + provTax > Totaltax, then adjust provTax to be totalTax - fedtax so that the sum of both of them is 500.00
>
>
>
>	totalTax  = 500.00
>	f = .05
>	p = .095
>	
>	base =  round(totalTax  / (f*p + f + p), 2)
>
>	
>	for i = base  - .50 to base + 0.50 step .01
>		fedTax = round(i * f, 2)
>		provTax = round((i + fedTax) * p, 2)
>		
>		if ( fedTax + provTax == totalTax  )
>		
>			? 'Base ' , i
>			? 'fedtax', fedTax 
>			? 'provTax ', provTax 
>			exit
>		endif
>		
>		if( fedTax + provTax > totalTax  )
>			provTax = totalTax  - fedtax
>			? 'Base ' , i
>			? 'fedtax', fedTax 
>			? 'provTax ', provTax 
>			
>			exit
>		endif
>		
>	endfor
>
The problem I had initially, and still have it with the IF addition, is that if I enter something else than 74.88 for the value, the program falls into an ongoing process. I have to force a brute force close of the application.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform