[psaux] Use `FT_SqrtFixed`.

* src/psaux/cffdecode.c <cff_op_sqrt>: Call `FT_SqrtFixed`.
* src/psaux/psintrp.c <cf2_escSQRT>: Ditto.
This commit is contained in:
Alexei Podtelezhnikov 2023-09-19 22:29:14 -04:00
parent 95b0fe2a6d
commit c4073d8251
2 changed files with 3 additions and 31 deletions

View File

@ -1753,22 +1753,9 @@
/* without upper limit the loop below might not finish */
if ( args[0] > 0x7FFFFFFFL )
args[0] = 0xB504F3L; /* sqrt( 32768.0 ) */
args[0] = 0xB504F4L; /* sqrt( 32768.0044 ) */
else if ( args[0] > 0 )
{
FT_Fixed root = 1 << ( ( 17 + FT_MSB( args[0] ) ) >> 1 );
FT_Fixed new_root;
for (;;)
{
new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1;
if ( new_root == root )
break;
root = new_root;
}
args[0] = new_root;
}
args[0] = (FT_Fixed)FT_SqrtFixed( args[0] );
else
args[0] = 0;
args++;

View File

@ -2276,22 +2276,7 @@
arg = cf2_stack_popFixed( opStack );
if ( arg > 0 )
{
/* initial guess based on the most significant bit */
FT_Fixed root = 1 << ( ( 17 + FT_MSB( arg ) ) >> 1 );
FT_Fixed new_root;
/* Babylonian method */
for (;;)
{
new_root = ( root + FT_DivFix( arg, root ) + 1 ) >> 1;
if ( new_root == root )
break;
root = new_root;
}
arg = new_root;
}
arg = (CF2_F16Dot16)FT_SqrtFixed( arg );
else
arg = 0;