Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reduce to zero
Message
De
05/02/2009 12:35:03
 
 
À
05/02/2009 12:24:02
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:
01379551
Vues:
19
>>>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.
>>
>>Well, I've rethought it, and personally, I'm stumped. If you don't know the starting value, and you don't know which step you're on, then you can't know if the number you have is already reduced partially (or even completely) or not. I don't see how it's possible to do without knowing either of those parameters.
>>
>>Gonna take somebody smarter than me to come up with it.
>
>Hi Alan. Well at least I am not the only one stuck on it :) The closest I have gotten is to reduce the previous value by a fixed percentage, around 20%, and if the value drops to less than 0.1 assume it to be "good enough" and force the value to zero. It doesn't work in exactly 10 steps, sometimes more, sometimes less, but gets close enough to what I am trying to achieve within the range of values I will be working with.

What sort of range of numbers are you working with?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform