3 inline int32_t fixmul31(int32_t x
, int32_t y
)
9 temp
>>= 31; //16+31-16 = 31 bits
15 * Fast integer square root adapted from algorithm,
16 * Martin Guy @ UKC, June 1985.
17 * Originally from a book on programming abaci by Mr C. Woo.
18 * This is taken from :
19 * http://wiki.forum.nokia.com/index.php/How_to_use_fixed_point_maths#How_to_get_square_root_for_integers
20 * with a added shift up of the result by 8 bits to return result in 16.16 fixed-point representation.
22 inline int32_t fastSqrt(int32_t n
)
25 * Logically, these are unsigned.
26 * We need the sign bit to test
27 * whether (op - res - one) underflowed.
32 /* "one" starts at the highest power of four <= than the argument. */
33 one
= 1 << 30; /* second-to-top bit set */
34 while (one
> op
) one
>>= 2;
39 op
= op
- (res
+ one
);
48 inline int32_t fixmul16(int32_t x
, int32_t y
)
59 inline int32_t fixdiv16(int32_t x
, int32_t y
)