Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Request code
Message
De
17/09/2008 01:49:23
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2008 Server
Database:
Visual FoxPro
Divers
Thread ID:
01347514
Message ID:
01348113
Vues:
23
The way I understood it - see original message -
If not exactly equal to 1.7, then it is to be rounded up to the next higher .1
That is where the mod() comes in

I did not want 1.709 to get truncated to 1.7
Original message:

I have create a form I have placed four text boxes namely 1.txtfirst 2.txtsecond 3. txtthree 4..txttotal. I want txttotal value rounded up next to 10.

Let assume the txttotal value is 8362 I want rounded to 8370

Anything more than 8360 gets an 'upgrade' to 8370


>It's not that simple. The result should be 1.7 but it's 1.8
>
>	? 1.701, RoundUp(1.701, 1)
>
>
>>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
>>
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform