zen
06-09-2001, 03:32 PM
Say I have a floating point value x taht is in the range [TINY...BIG].Now I want to take the square root of x and map it to an integer using a log scale.Of course I coudl do this:
f=sqrt(x);
i=(int)floor((float)MAX_VAL*((log(f)-log(TINY))/(log(BIG)-log(TINY))));
That will take the sqrt of x and map it to an integer from 0 to MAX_VAL.That's what I'm doing now but it's slow.What I want to do is use the lookup table to do the sqrts and logs.Problem is how do I do that for the range {TINY...BIG].Does anybody know of any on-line docs about lookup tables?Thanks in advance for any help.
f=sqrt(x);
i=(int)floor((float)MAX_VAL*((log(f)-log(TINY))/(log(BIG)-log(TINY))));
That will take the sqrt of x and map it to an integer from 0 to MAX_VAL.That's what I'm doing now but it's slow.What I want to do is use the lookup table to do the sqrts and logs.Problem is how do I do that for the range {TINY...BIG].Does anybody know of any on-line docs about lookup tables?Thanks in advance for any help.