Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Request code
Message
From
15/09/2008 09:17:54
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2008 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01347514
Message ID:
01347578
Views:
15
I had something like this in my mind - same parameters as Round()
	? 8160, RoundUp(8160, -1)
	? 8161, RoundUp(8161, -1)
	
	? -8160, RoundUp(-8160, -1)
	? -8161, RoundUp(-8161, -1)
	
	? 1.4, RoundUp(1.4, 1)
	? 1.4, RoundUp(1.4, 0)
	? 1.4, RoundUp(1.4, -1)
	
	
	? 1.7, RoundUp(1.7, 2)
	? 1.7, RoundUp(1.7, 1)
	? 1.7, RoundUp(1.7, 0)
	? 1.7, RoundUp(1.7, -1)
	? 1.7, RoundUp(1.7, -2)
	
	? 1.711, RoundUp(1.711, 2)
	
	? 1.71, RoundUp(1.71, 2)
	? 1.71, RoundUp(1.71, 1)
	? 1.71, RoundUp(1.71, 0)
	? 1.71, RoundUp(1.71, -1)
	? 1.71, RoundUp(1.71, -2)

function RoundUp(n, ndecimal)

	return round(m.n + sign(m.n) * iif(empty(mod(m.n, 10^(-m.ndecimal))), 0, 10^(-m.ndecimal)/2), m.ndecimal)
	
endfunc

>My mistake. I didn't notice the 'round up' part.
>
>CLEAR
>
>FOR i=8359 TO 8371
>  ? i, RoundupTo10(i)
>ENDFOR
>
>FUNCTION RoundupTo10(tnValue)
>RETURN ROUND(tnValue + 4.9,-1)
>
>
>>Round() won't work for the first example - Ceiling is better - but works different for negative numbers
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform