davedwards
Feb 15th, 2002, 08:25 PM
I didn't go over it in any too much detail, but one simple improvement I saw was this.
Temp = 0.5 * (Upper - Lower) + Lower
Can be rewritten as
Temp = (Upper + Lower) \ 2
In VB '\' is an Integer Divide and It is faster (or should be, I think) than multiplying by 0.5 because it does not have to convert from floating point to an integer. Also if you do the algebra you will see that you can save one less operation. Finding the middle value of two numbers is the same mathematically of finding the average of the two numbers.
Probably an unnoticable improvement, but it is very common to find the middle of two values.
Temp = 0.5 * (Upper - Lower) + Lower
Can be rewritten as
Temp = (Upper + Lower) \ 2
In VB '\' is an Integer Divide and It is faster (or should be, I think) than multiplying by 0.5 because it does not have to convert from floating point to an integer. Also if you do the algebra you will see that you can save one less operation. Finding the middle value of two numbers is the same mathematically of finding the average of the two numbers.
Probably an unnoticable improvement, but it is very common to find the middle of two values.