Minor refactoring.

* src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Updated.
This commit is contained in:
Alexei Podtelezhnikov 2014-08-14 23:21:46 -04:00
parent c7022467d2
commit 5ef2023c45
2 changed files with 17 additions and 9 deletions

View File

@ -1,4 +1,10 @@
2014-08-13 Alexei Podtelezhnikov <apodtele@gmail.com>
2014-08-14 Alexei Podtelezhnikov <apodtele@gmail.com>
Minor refactoring.
* src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Updated.
2014-08-14 Alexei Podtelezhnikov <apodtele@gmail.com>
Turn FT_MSB into a macro when using gcc builtins.

View File

@ -400,10 +400,13 @@
s ^= b; b = FT_ABS( b );
s ^= c; c = FT_ABS( c );
if ( (FT_ULong)a + (FT_ULong)b <= 92681UL - ( c >> 16 ) && c > 0 )
if ( c == 0 )
a = 0x7FFFFFFFL;
else if ( (FT_ULong)a + (FT_ULong)b <= 92681UL - ( c >> 16 ) )
a = ( a * b + ( c >> 1 ) ) / c;
else if ( (FT_Int32)c > 0 )
else
{
FT_Int64 temp, temp2;
@ -415,8 +418,6 @@
FT_Add64( &temp, &temp2, &temp );
a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
}
else
a = 0x7FFFFFFFL;
return ( s < 0 ? -a : a );
}
@ -437,10 +438,13 @@
s ^= b; b = FT_ABS( b );
s ^= c; c = FT_ABS( c );
if ( (FT_ULong)a + (FT_ULong)b <= 92681UL && c > 0 )
if ( c == 0 )
a = 0x7FFFFFFFL;
else if ( (FT_ULong)a + (FT_ULong)b <= 92681UL )
a = a * b / c;
else if ( (FT_Int32)c > 0 )
else
{
FT_Int64 temp;
@ -448,8 +452,6 @@
ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
}
else
a = 0x7FFFFFFFL;
return ( s < 0 ? -a : a );
}