LibreOffice Module tools (master) 1
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
BigInt Class Reference

#include <bigint.hxx>

Public Member Functions

 BigInt ()
 
 BigInt (sal_Int32 nValue)
 
 BigInt (double nVal)
 
 BigInt (sal_uInt32 nVal)
 
 BigInt (sal_Int64 nVal)
 
 BigInt (const BigInt &rBigInt)
 
 BigInt (std::u16string_view rString)
 
 operator sal_Int16 () const
 
 operator sal_uInt16 () const
 
 operator sal_Int32 () const
 
 operator sal_uInt32 () const
 
 operator double () const
 
bool IsNeg () const
 
bool IsZero () const
 
bool IsLong () const
 
void Abs ()
 
BigIntoperator= (const BigInt &rVal)
 
BigIntoperator+= (const BigInt &rVal)
 
BigIntoperator-= (const BigInt &rVal)
 
BigIntoperator*= (const BigInt &rVal)
 
BigIntoperator/= (const BigInt &rVal)
 
BigIntoperator%= (const BigInt &rVal)
 
BigIntoperator= (sal_Int32 nValue)
 

Static Public Member Functions

static tools::Long Scale (tools::Long nVal, tools::Long nMult, tools::Long nDiv)
 

Private Member Functions

TOOLS_DLLPRIVATE void MakeBigInt (BigInt const &)
 
TOOLS_DLLPRIVATE void Normalize ()
 
TOOLS_DLLPRIVATE void Mult (BigInt const &, sal_uInt16)
 
TOOLS_DLLPRIVATE void Div (sal_uInt16, sal_uInt16 &)
 
TOOLS_DLLPRIVATE bool IsLess (BigInt const &) const
 
TOOLS_DLLPRIVATE void AddLong (BigInt &, BigInt &)
 
TOOLS_DLLPRIVATE void SubLong (BigInt &, BigInt &)
 
TOOLS_DLLPRIVATE void MultLong (BigInt const &, BigInt &) const
 
TOOLS_DLLPRIVATE void DivLong (BigInt const &, BigInt &) const
 
TOOLS_DLLPRIVATE void ModLong (BigInt const &, BigInt &) const
 
TOOLS_DLLPRIVATE bool ABS_IsLess (BigInt const &) const
 

Private Attributes

union {
   sal_Int32   nVal
 
   sal_uInt16   nNum [MAX_DIGITS]
 
}; 
 
sal_uInt8 nLen: 5
 
bool bIsNeg: 1
 

Friends

class Fraction
 
BigInt operator+ (const BigInt &rVal1, const BigInt &rVal2)
 
BigInt operator- (const BigInt &rVal1, const BigInt &rVal2)
 
BigInt operator* (const BigInt &rVal1, const BigInt &rVal2)
 
BigInt operator/ (const BigInt &rVal1, const BigInt &rVal2)
 
BigInt operator% (const BigInt &rVal1, const BigInt &rVal2)
 
TOOLS_DLLPUBLIC friend bool operator== (const BigInt &rVal1, const BigInt &rVal2)
 
bool operator!= (const BigInt &rVal1, const BigInt &rVal2)
 
TOOLS_DLLPUBLIC friend bool operator< (const BigInt &rVal1, const BigInt &rVal2)
 
bool operator> (const BigInt &rVal1, const BigInt &rVal2)
 
bool operator<= (const BigInt &rVal1, const BigInt &rVal2)
 
bool operator>= (const BigInt &rVal1, const BigInt &rVal2)
 

Detailed Description

Definition at line 28 of file bigint.hxx.

Constructor & Destructor Documentation

◆ BigInt() [1/7]

BigInt::BigInt ( )
inline

Definition at line 52 of file bigint.hxx.

Referenced by operator%=(), and operator/=().

◆ BigInt() [2/7]

BigInt::BigInt ( sal_Int32  nValue)
inline

Definition at line 59 of file bigint.hxx.

References nValue.

◆ BigInt() [3/7]

BigInt::BigInt ( double  nVal)

Definition at line 508 of file bigint.cxx.

References bIsNeg, i, MAX_DIGITS, nLen, nNum, Normalize(), nVal, and nValue.

◆ BigInt() [4/7]

BigInt::BigInt ( sal_uInt32  nVal)

Definition at line 547 of file bigint.cxx.

References bIsNeg, nLen, nNum, nVal, and nValue.

◆ BigInt() [5/7]

BigInt::BigInt ( sal_Int64  nVal)

Definition at line 565 of file bigint.cxx.

References bIsNeg, i, nLen, nNum, nVal, nValue, SAL_MAX_INT32, and SAL_MIN_INT32.

◆ BigInt() [6/7]

BigInt::BigInt ( const BigInt rBigInt)

Definition at line 468 of file bigint.cxx.

References nLen, and nVal.

◆ BigInt() [7/7]

BigInt::BigInt ( std::u16string_view  rString)

Definition at line 478 of file bigint.cxx.

References bIsNeg, nLen, nVal, and p.

Member Function Documentation

◆ Abs()

void BigInt::Abs ( )
inline

Definition at line 191 of file bigint.hxx.

References bIsNeg, nLen, and nVal.

◆ ABS_IsLess()

bool BigInt::ABS_IsLess ( BigInt const &  rB) const
private

Definition at line 438 of file bigint.cxx.

References i, MakeBigInt(), nLen, nNum, and nVal.

Referenced by operator%=(), and operator/=().

◆ AddLong()

void BigInt::AddLong ( BigInt rB,
BigInt rErg 
)
private

Definition at line 156 of file bigint.cxx.

References bIsNeg, i, nLen, nNum, and SubLong().

Referenced by operator+=(), and SubLong().

◆ Div()

void BigInt::Div ( sal_uInt16  nDiv,
sal_uInt16 &  rRem 
)
private

Definition at line 127 of file bigint.cxx.

References i, nLen, and nNum.

Referenced by ModLong(), operator%=(), and operator/=().

◆ DivLong()

void BigInt::DivLong ( BigInt const &  rB,
BigInt rErg 
) const
private

Definition at line 307 of file bigint.cxx.

References bIsNeg, i, Mult(), nLen, and nNum.

Referenced by operator/=().

◆ IsLess()

bool BigInt::IsLess ( BigInt const &  rVal) const
private

Definition at line 142 of file bigint.cxx.

References i, nLen, and nNum.

Referenced by SubLong().

◆ IsLong()

bool BigInt::IsLong ( ) const
inline

Definition at line 92 of file bigint.hxx.

◆ IsNeg()

bool BigInt::IsNeg ( ) const
inline

Definition at line 175 of file bigint.hxx.

References bIsNeg, nLen, and nVal.

Referenced by Scale().

◆ IsZero()

bool BigInt::IsZero ( ) const
inline

Definition at line 183 of file bigint.hxx.

References nLen, and nVal.

◆ MakeBigInt()

void BigInt::MakeBigInt ( BigInt const &  rVal)
private

Definition at line 42 of file bigint.cxx.

References bIsNeg, nLen, nNum, and nVal.

Referenced by ABS_IsLess(), operator%=(), operator*=(), operator+=(), operator-=(), and operator/=().

◆ ModLong()

void BigInt::ModLong ( BigInt const &  rB,
BigInt rErg 
) const
private

Definition at line 373 of file bigint.cxx.

References Div(), i, Mult(), nLen, and nNum.

Referenced by operator%=().

◆ Mult()

void BigInt::Mult ( BigInt const &  rVal,
sal_uInt16  nMul 
)
private

Definition at line 106 of file bigint.cxx.

References bIsNeg, i, nLen, and nNum.

Referenced by DivLong(), and ModLong().

◆ MultLong()

void BigInt::MultLong ( BigInt const &  rB,
BigInt rErg 
) const
private

Definition at line 283 of file bigint.cxx.

References bIsNeg, i, nLen, and nNum.

Referenced by operator*=().

◆ Normalize()

void BigInt::Normalize ( )
private

Definition at line 74 of file bigint.cxx.

References bIsNeg, nLen, nNum, and nVal.

Referenced by BigInt(), operator%=(), operator*=(), operator+=(), operator-=(), and operator/=().

◆ operator double()

BigInt::operator double ( ) const

Definition at line 587 of file bigint.cxx.

References i.

◆ operator sal_Int16()

BigInt::operator sal_Int16 ( ) const
inline

Definition at line 124 of file bigint.hxx.

References SAL_MAX_INT16, and SAL_MIN_INT16.

◆ operator sal_Int32()

BigInt::operator sal_Int32 ( ) const
inline

Definition at line 140 of file bigint.hxx.

◆ operator sal_uInt16()

BigInt::operator sal_uInt16 ( ) const
inline

Definition at line 132 of file bigint.hxx.

References SAL_MAX_UINT16.

◆ operator sal_uInt32()

BigInt::operator sal_uInt32 ( ) const
inline

Definition at line 148 of file bigint.hxx.

◆ operator%=()

BigInt & BigInt::operator%= ( const BigInt rVal)

Definition at line 759 of file bigint.cxx.

References ABS_IsLess(), BigInt(), bIsNeg, Div(), MakeBigInt(), ModLong(), nLen, Normalize(), and nVal.

◆ operator*=()

BigInt & BigInt::operator*= ( const BigInt rVal)

Definition at line 677 of file bigint.cxx.

References MakeBigInt(), MultLong(), nLen, Normalize(), and nVal.

◆ operator+=()

BigInt & BigInt::operator+= ( const BigInt rVal)

Definition at line 625 of file bigint.cxx.

References AddLong(), MakeBigInt(), MY_MAXLONG, MY_MINLONG, nLen, Normalize(), and nVal.

◆ operator-=()

BigInt & BigInt::operator-= ( const BigInt rVal)

Definition at line 651 of file bigint.cxx.

References MakeBigInt(), MY_MAXLONG, MY_MINLONG, nLen, Normalize(), nVal, and SubLong().

◆ operator/=()

BigInt & BigInt::operator/= ( const BigInt rVal)

Definition at line 700 of file bigint.cxx.

References ABS_IsLess(), BigInt(), bIsNeg, Div(), DivLong(), MakeBigInt(), nLen, Normalize(), and nVal.

◆ operator=() [1/2]

BigInt & BigInt::operator= ( const BigInt rVal)

Definition at line 610 of file bigint.cxx.

References nLen, and nVal.

◆ operator=() [2/2]

BigInt & BigInt::operator= ( sal_Int32  nValue)
inline

Definition at line 167 of file bigint.hxx.

References nLen, nVal, and nValue.

◆ Scale()

tools::Long BigInt::Scale ( tools::Long  nVal,
tools::Long  nMult,
tools::Long  nDiv 
)
static

Definition at line 836 of file bigint.cxx.

References IsNeg(), and nVal.

◆ SubLong()

void BigInt::SubLong ( BigInt rB,
BigInt rErg 
)
private

Definition at line 214 of file bigint.cxx.

References AddLong(), bIsNeg, i, IsLess(), nLen, and nNum.

Referenced by AddLong(), and operator-=().

Friends And Related Function Documentation

◆ Fraction

friend class Fraction
friend

Definition at line 121 of file bigint.hxx.

◆ operator!=

bool operator!= ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 234 of file bigint.hxx.

◆ operator%

BigInt operator% ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 227 of file bigint.hxx.

◆ operator*

BigInt operator* ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 213 of file bigint.hxx.

◆ operator+

BigInt operator+ ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 199 of file bigint.hxx.

◆ operator-

BigInt operator- ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 206 of file bigint.hxx.

◆ operator/

BigInt operator/ ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 220 of file bigint.hxx.

◆ operator<

TOOLS_DLLPUBLIC friend bool operator< ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 818 of file bigint.cxx.

◆ operator<=

bool operator<= ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 241 of file bigint.hxx.

◆ operator==

TOOLS_DLLPUBLIC friend bool operator== ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 806 of file bigint.cxx.

◆ operator>

bool operator> ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 239 of file bigint.hxx.

◆ operator>=

bool operator>= ( const BigInt rVal1,
const BigInt rVal2 
)
friend

Definition at line 246 of file bigint.hxx.

Member Data Documentation

◆ 

union { ... } BigInt::@2

◆ bIsNeg

bool BigInt::bIsNeg
private

◆ nLen

sal_uInt8 BigInt::nLen
private

◆ nNum

sal_uInt16 BigInt::nNum[MAX_DIGITS]

◆ nVal

sal_Int32 BigInt::nVal

The documentation for this class was generated from the following files: