Minor refactoring.
* src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round): Updated.
This commit is contained in:
parent
c7022467d2
commit
5ef2023c45
|
@ -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.
|
Turn FT_MSB into a macro when using gcc builtins.
|
||||||
|
|
||||||
|
|
|
@ -400,10 +400,13 @@
|
||||||
s ^= b; b = FT_ABS( b );
|
s ^= b; b = FT_ABS( b );
|
||||||
s ^= c; c = FT_ABS( c );
|
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;
|
a = ( a * b + ( c >> 1 ) ) / c;
|
||||||
|
|
||||||
else if ( (FT_Int32)c > 0 )
|
else
|
||||||
{
|
{
|
||||||
FT_Int64 temp, temp2;
|
FT_Int64 temp, temp2;
|
||||||
|
|
||||||
|
@ -415,8 +418,6 @@
|
||||||
FT_Add64( &temp, &temp2, &temp );
|
FT_Add64( &temp, &temp2, &temp );
|
||||||
a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
|
a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
a = 0x7FFFFFFFL;
|
|
||||||
|
|
||||||
return ( s < 0 ? -a : a );
|
return ( s < 0 ? -a : a );
|
||||||
}
|
}
|
||||||
|
@ -437,10 +438,13 @@
|
||||||
s ^= b; b = FT_ABS( b );
|
s ^= b; b = FT_ABS( b );
|
||||||
s ^= c; c = FT_ABS( c );
|
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;
|
a = a * b / c;
|
||||||
|
|
||||||
else if ( (FT_Int32)c > 0 )
|
else
|
||||||
{
|
{
|
||||||
FT_Int64 temp;
|
FT_Int64 temp;
|
||||||
|
|
||||||
|
@ -448,8 +452,6 @@
|
||||||
ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
|
ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
|
||||||
a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
|
a = ft_div64by32( temp.hi, temp.lo, (FT_Int32)c );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
a = 0x7FFFFFFFL;
|
|
||||||
|
|
||||||
return ( s < 0 ? -a : a );
|
return ( s < 0 ? -a : a );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue