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

Method Div2_Calculate

extern/ttmath/ttmathuint.h:1869–1903  ·  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

1867
1868 */
1869 uint Div2_Calculate(const UInt<value_size> & divisor, UInt<value_size> * remainder,
1870 uint & bits_diff)
1871 {
1872 uint table_id, index;
1873 uint divisor_table_id, divisor_index;
1874
1875 uint status = Div2_FindLeadingBitsAndCheck( divisor, remainder,
1876 table_id, index,
1877 divisor_table_id, divisor_index);
1878
1879 if( status < 2 )
1880 {
1881 TTMATH_LOG("UInt::Div2_Calculate")
1882 return status;
1883 }
1884
1885 // here we know that 'this' is greater than divisor
1886 // then 'index' is greater or equal 'divisor_index'
1887 bits_diff = index - divisor_index;
1888
1889 UInt<value_size> divisor_copy(divisor);
1890 divisor_copy.Rcl(bits_diff, 0);
1891
1892 if( CmpSmaller(divisor_copy, table_id) )
1893 {
1894 divisor_copy.Rcr(1);
1895 --bits_diff;
1896 }
1897
1898 Sub(divisor_copy, 0);
1899
1900 TTMATH_LOG("UInt::Div2_Calculate")
1901
1902 return 2;
1903 }
1904
1905
1906 /*!

Callers

nothing calls this directly

Calls 2

RclMethod · 0.80
RcrMethod · 0.80

Tested by

no test coverage detected