Jorgea
January 5th, 2008, 07:36 AM
1. In general programming, if you want to 'scan', or
do a calculation till the calculated value is closest
to some other value, how do you personally approach
it. I mean your ´thought process or flow chart. The
reason why I ask is that, I have always used the
approach where I use a Do loop till the calculated
value is greater than or equal to the test value. The
problem i have encountered is that at times the
closest value is actually JUST BEFORE the test value,
but I am confused as to what test clause to use. For
eg. 7.98 is closer to 8.00 than 8.04 is. So the code
is likely to fish out 8.04 whereas 7.98 was a better
answer.
I normally attempt to test with a range test clause.
i.e the test clause will read something like DO until
calc value is within 0.99Test val and 1.01Test val.
The problem I have encountered at times is that the
program simply 'dodges' the test val and simply hangs
since it just goes on indefinitely. The solution
should be pretty simple w/o any special program
specific command but I just can't figure it out. I
need more exact answers in a number of my programs. I
need fine tuned answers. Can anyone be of help?....with
typical foolproof test clauses I could use in my Do
loop structures?
Thanks for ur assistance!!!
do a calculation till the calculated value is closest
to some other value, how do you personally approach
it. I mean your ´thought process or flow chart. The
reason why I ask is that, I have always used the
approach where I use a Do loop till the calculated
value is greater than or equal to the test value. The
problem i have encountered is that at times the
closest value is actually JUST BEFORE the test value,
but I am confused as to what test clause to use. For
eg. 7.98 is closer to 8.00 than 8.04 is. So the code
is likely to fish out 8.04 whereas 7.98 was a better
answer.
I normally attempt to test with a range test clause.
i.e the test clause will read something like DO until
calc value is within 0.99Test val and 1.01Test val.
The problem I have encountered at times is that the
program simply 'dodges' the test val and simply hangs
since it just goes on indefinitely. The solution
should be pretty simple w/o any special program
specific command but I just can't figure it out. I
need more exact answers in a number of my programs. I
need fine tuned answers. Can anyone be of help?....with
typical foolproof test clauses I could use in my Do
loop structures?
Thanks for ur assistance!!!