Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reduce to zero
Message
De
05/02/2009 12:12:03
 
 
À
05/02/2009 11:19:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01379529
Message ID:
01379538
Vues:
25
>Here is probably a simple math problem but I seem to have a mental block:
>
>I want to reduce any given number to zero in 10 steps or loops. In each loop iteration I only have access to the previous value, not the initial starting value. I was thinking of subtracting a percentage off the previous value but that will not reduce to zero in 10 steps especially given that the number can have up to 4 decimals. Any obvious solution?
>
>Update: I also cannot know what iteration I am on. In other words, I want to reduce a number by some formula and know that within +/-10 iterations the number will fall to zero.

Dunno Jos, but wouldn't the step value be (InitialValue / 10) ?

If the number is not 'easily' divided by 10, ie (InitialValue / 10) * 10 != InitialValue, you could always populate a Collection with the first 9 values and the tenth value would be InitialValue - first 9 stepvalues

I would go for the collection approach regardless. You feed the collection and loop - removing one item at a time - until it's empty
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform