* src/base/ftcalc.c /* FT_SqrtFixed */: Fix defunct overflow.

This commit is contained in:
Alexei Podtelezhnikov 2023-09-18 15:01:26 +00:00
parent d7b63a966b
commit babe6af167
1 changed files with 10 additions and 8 deletions

View File

@ -917,17 +917,18 @@
/* documentation is in ftcalc.h */
/* Algorithm and code by Christophe Meessen (1993). */
/* Algorithm and code by Christophe Meessen (1993) */
/* with overflow fixed. */
FT_BASE_DEF( FT_UInt32 )
FT_SqrtFixed( FT_UInt32 r )
FT_SqrtFixed( FT_UInt32 v )
{
FT_UInt32 t, q, b;
FT_UInt32 r = v >> 1;
FT_UInt32 q = ( v & 1 ) << 15;
FT_UInt32 b = 0x20000000;
FT_UInt32 t;
q = 0;
b = 0x40000000;
while ( b > 0x40 )
do
{
t = q + b;
if ( r >= t )
@ -938,8 +939,9 @@
r <<= 1;
b >>= 1;
}
while ( b > 0x20 );
return q >> 8;
return q >> 7;
}
#endif /* 0 */