Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reduce to zero
Message
From
05/02/2009 12:24:02
 
 
To
05/02/2009 12:20:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01379529
Message ID:
01379543
Views:
14
>>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.
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform