Advertisement

Fast exponential function

Started by October 26, 2001 09:43 PM
0 comments, last by Premandrake 23 years, 3 months ago
Hello all, I''m trying to improve my exponential function and need some help. The current version is posted below:
  
float pow(float base,float exp)
{
 float tmpVal;
 _asm
 {
  fld [exp];
  fld [base];
  fyl2x;		// exp * log2(base)

  fld1;
  fld st(1);				
  fprem;		// remainder ((exp * log2(base)) / 1)

  f2xm1;		// (2 ^ remainder) - 1

  faddp st(1),st(0);	// (exp * log2(base)) + ((2 ^ remainder) - 1)

  fscale;		// (2 ^ int(st1)) * st0

  fstp [tmpVal];	// Phew done ;)

 }
 return tmpVal;
}
  
Now, what I''d like to do is split up on of these operations into an integer/float part so that it can work in parallel. Unfortunately this has proven much harder to do then I thought. For example, all the fprem does is find the fractional part of st(0), but coming up with a method to do that quickly in integer math is proving very difficult. Any suggestions? Gary
Maybe a look-up table?

This topic is closed to new replies.

Advertisement