MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / PositiveDivide

Function PositiveDivide

src/cryptlib/integer.cpp:1876–1909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1874*/
1875
1876void PositiveDivide(Integer &remainder, Integer &quotient,
1877 const Integer &a, const Integer &b)
1878{
1879 unsigned aSize = a.WordCount();
1880 unsigned bSize = b.WordCount();
1881
1882 if (!bSize)
1883 {
1884#ifdef THROW_EXCEPTIONS
1885 throw Integer::DivideByZero();
1886#else
1887 return;
1888#endif
1889 }
1890
1891 if (a.PositiveCompare(b) == -1)
1892 {
1893 remainder = a;
1894 remainder.sign = Integer::POSITIVE;
1895 quotient = Integer::Zero();
1896 return;
1897 }
1898
1899 aSize += aSize%2; // round up to next even number
1900 bSize += bSize%2;
1901
1902 remainder.reg.CleanNew(RoundupSize(bSize));
1903 remainder.sign = Integer::POSITIVE;
1904 quotient.reg.CleanNew(RoundupSize(aSize-bSize+2));
1905 quotient.sign = Integer::POSITIVE;
1906
1907 SecWordBlock T(aSize+2*bSize+4);
1908 Divide(remainder.reg, quotient.reg, T, a.reg, aSize, b.reg, bSize);
1909}
1910
1911void Integer::Divide(Integer &remainder, Integer &quotient, const Integer &dividend, const Integer &divisor)
1912{

Callers 1

DivideMethod · 0.85

Calls 6

DivideByZeroClass · 0.85
RoundupSizeFunction · 0.85
DivideFunction · 0.85
WordCountMethod · 0.80
PositiveCompareMethod · 0.80
CleanNewMethod · 0.80

Tested by

no test coverage detected