MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / RootCorrectInteger

Function RootCorrectInteger

extern/ttmath/ttmath.h:2023–2045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2021
2022 template<class ValueType>
2023 uint RootCorrectInteger(ValueType & old_x, ValueType & x, const ValueType & index)
2024 {
2025 if( !old_x.IsInteger() || x.IsInteger() || !index.exponent.IsSign() )
2026 return 0;
2027
2028 // old_x is integer,
2029 // x is not integer,
2030 // index is relatively small (index.exponent<0 or index.exponent<=0)
2031 // (because we're using a special powering algorithm Big::PowUInt())
2032
2033 uint c = 0;
2034
2035 ValueType temp(x);
2036 c += temp.Round();
2037
2038 ValueType temp_round(temp);
2039 c += temp.PowUInt(index);
2040
2041 if( temp == old_x )
2042 x = temp_round;
2043
2044 return (c==0)? 0 : 1;
2045 }
2046
2047
2048

Callers 1

RootFunction · 0.85

Calls 1

IsSignMethod · 0.80

Tested by

no test coverage detected