|
|
|
@ -917,36 +917,29 @@ |
|
|
|
|
|
|
|
|
|
/* documentation is in ftcalc.h */ |
|
|
|
|
|
|
|
|
|
FT_BASE_DEF( FT_Int32 ) |
|
|
|
|
FT_SqrtFixed( FT_Int32 x ) |
|
|
|
|
/* Algorithm and code by Christophe Meessen (1993). */ |
|
|
|
|
FT_BASE_DEF( FT_UInt32 ) |
|
|
|
|
FT_SqrtFixed( FT_UInt32 r ) |
|
|
|
|
{ |
|
|
|
|
FT_UInt32 root, rem_hi, rem_lo, test_div; |
|
|
|
|
FT_Int count; |
|
|
|
|
FT_UInt32 t, q, b; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root = 0; |
|
|
|
|
q = 0; |
|
|
|
|
|
|
|
|
|
if ( x > 0 ) |
|
|
|
|
b = 0x40000000; |
|
|
|
|
while ( b > 0x40 ) |
|
|
|
|
{ |
|
|
|
|
rem_hi = 0; |
|
|
|
|
rem_lo = (FT_UInt32)x; |
|
|
|
|
count = 24; |
|
|
|
|
do |
|
|
|
|
t = q + b; |
|
|
|
|
if ( r >= t ) |
|
|
|
|
{ |
|
|
|
|
rem_hi = ( rem_hi << 2 ) | ( rem_lo >> 30 ); |
|
|
|
|
rem_lo <<= 2; |
|
|
|
|
root <<= 1; |
|
|
|
|
test_div = ( root << 1 ) + 1; |
|
|
|
|
|
|
|
|
|
if ( rem_hi >= test_div ) |
|
|
|
|
{ |
|
|
|
|
rem_hi -= test_div; |
|
|
|
|
root += 1; |
|
|
|
|
} |
|
|
|
|
} while ( --count ); |
|
|
|
|
r -= t; |
|
|
|
|
q = t + b; /* equivalent to q += 2*b */ |
|
|
|
|
} |
|
|
|
|
r <<= 1; |
|
|
|
|
b >>= 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return (FT_Int32)root; |
|
|
|
|
return q >> 8; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endif /* 0 */ |
|
|
|
|