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

Method Div2_FindLeadingBitsAndCheck

extern/ttmath/ttmathuint.h:1912–1972  ·  view source on GitHub ↗

! return values: 0 - we've calculated the division 1 - division by zero 2 - we have to still calculate */

Source from the content-addressed store, hash-verified

1910 2 - we have to still calculate
1911 */
1912 uint Div2_FindLeadingBitsAndCheck( const UInt<value_size> & divisor,
1913 UInt<value_size> * remainder,
1914 uint & table_id, uint & index,
1915 uint & divisor_table_id, uint & divisor_index)
1916 {
1917 if( !divisor.FindLeadingBit(divisor_table_id, divisor_index) )
1918 {
1919 // division by zero
1920 TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
1921 return 1;
1922 }
1923
1924 if( !FindLeadingBit(table_id, index) )
1925 {
1926 // zero is divided by something
1927
1928 SetZero();
1929
1930 if( remainder )
1931 remainder->SetZero();
1932
1933 TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
1934
1935 return 0;
1936 }
1937
1938 divisor_index += divisor_table_id * TTMATH_BITS_PER_UINT;
1939 index += table_id * TTMATH_BITS_PER_UINT;
1940
1941 if( divisor_table_id == 0 )
1942 {
1943 // dividor has only one 32-bit word
1944
1945 uint r;
1946 DivInt(divisor.table[0], &r);
1947
1948 if( remainder )
1949 {
1950 remainder->SetZero();
1951 remainder->table[0] = r;
1952 }
1953
1954 TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
1955
1956 return 0;
1957 }
1958
1959
1960 if( Div2_DivisorGreaterOrEqual( divisor, remainder,
1961 table_id, index,
1962 divisor_index) )
1963 {
1964 TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")
1965 return 0;
1966 }
1967
1968
1969 TTMATH_LOG("UInt::Div2_FindLeadingBitsAndCheck")

Callers

nothing calls this directly

Calls 2

FindLeadingBitMethod · 0.80
SetZeroMethod · 0.80

Tested by

no test coverage detected