GnuCash c935c2f+
Loading...
Searching...
No Matches
Data Structures | Functions

provides a 125-bit int as a base class for GncNumeric. More...

Data Structures

class  GncInt128
 

Functions

GncInt128 operator+ (GncInt128 a, const GncInt128 &b) noexcept
 
GncInt128 operator- (GncInt128 a, const GncInt128 &b) noexcept
 
GncInt128 operator* (GncInt128 a, const GncInt128 &b) noexcept
 
GncInt128 operator/ (GncInt128 a, const GncInt128 &b) noexcept
 
GncInt128 operator% (GncInt128 a, const GncInt128 &b) noexcept
 
GncInt128 operator& (GncInt128 a, const GncInt128 &b) noexcept
 
GncInt128 operator| (GncInt128 a, const GncInt128 &b) noexcept
 
GncInt128 operator^ (GncInt128 a, const GncInt128 &b) noexcept
 
GncInt128 operator<< (GncInt128 a, unsigned int b) noexcept
 
GncInt128 operator>> (GncInt128 a, unsigned int b) noexcept
 
bool operator== (const GncInt128 &a, const GncInt128 &b) noexcept
 
bool operator!= (const GncInt128 &a, const GncInt128 &b) noexcept
 
bool operator<= (const GncInt128 &a, const GncInt128 &b) noexcept
 
bool operator>= (const GncInt128 &a, const GncInt128 &b) noexcept
 
bool operator< (const GncInt128 &a, const GncInt128 &b) noexcept
 
bool operator> (const GncInt128 &a, const GncInt128 &b) noexcept
 
std::ostream & operator<< (std::ostream &, const GncInt128 &) noexcept
 
GncInt128 gcd (int64_t a, int64_t b)
 Compute the greatest common denominator of two integers.
 
GncInt128 lcm (int64_t a, int64_t b)
 Compute the least common multiple of two integers.
 

Detailed Description

provides a 125-bit int as a base class for GncNumeric.

In order to make space for the status flags the upper leg is limited to 0x1fffffffffffffff. Attempting to construct a GncInt128 with a larger upper leg will throw a std::overflow_error.

All the usual operators are provided. Only the constructors and explicit integer conversions throw; all other errors are indicated by the overflow and NaN ("Not a Number") flags. Note that performing any operation on an overflowed or NaN Gncint128 will yield an overflowed or NaN result, so calling routines need not check until the end of a chained calculation. GncInt128 uses implicit copy and move constructors and implicit destructor.

Function Documentation

◆ operator!=()

bool operator!= ( const GncInt128 a,
const GncInt128 b 
)
noexcept

Definition at line 972 of file gnc-int128.cpp.

973{
974 return a.cmp(b) != 0;
975}

◆ operator%()

GncInt128 operator% ( GncInt128  a,
const GncInt128 b 
)
noexcept

Definition at line 1029 of file gnc-int128.cpp.

1030{
1031 a %= b;
1032 return a;
1033}

◆ operator&()

GncInt128 operator& ( GncInt128  a,
const GncInt128 b 
)
noexcept

Definition at line 1036 of file gnc-int128.cpp.

1037{
1038 a &= b;
1039 return a;
1040}

◆ operator*()

GncInt128 operator* ( GncInt128  a,
const GncInt128 b 
)
noexcept

Definition at line 1015 of file gnc-int128.cpp.

1016{
1017 a *= b;
1018 return a;
1019}

◆ operator+()

GncInt128 operator+ ( GncInt128  a,
const GncInt128 b 
)
noexcept

Definition at line 1002 of file gnc-int128.cpp.

1003{
1004 a += b;
1005 return a;
1006}

◆ operator-()

GncInt128 operator- ( GncInt128  a,
const GncInt128 b 
)
noexcept

Definition at line 1009 of file gnc-int128.cpp.

1010{
1011 a -= b;
1012 return a;
1013}

◆ operator/()

GncInt128 operator/ ( GncInt128  a,
const GncInt128 b 
)
noexcept

Definition at line 1022 of file gnc-int128.cpp.

1023{
1024 a /= b;
1025 return a;
1026}

◆ operator<()

bool operator< ( const GncInt128 a,
const GncInt128 b 
)
noexcept

Definition at line 977 of file gnc-int128.cpp.

979{
980 return a.cmp(b) < 0;
981}

◆ operator<<() [1/2]

GncInt128 operator<< ( GncInt128  a,
unsigned int  b 
)
noexcept

Definition at line 1056 of file gnc-int128.cpp.

1058{
1059 a <<= b;
1060 return a;
1061}

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  stream,
const GncInt128 a 
)
noexcept

Definition at line 957 of file gnc-int128.cpp.

959{
960 char buf[char_buf_size] {};
961 stream << a.asCharBufR (buf, char_buf_size - 1);
962 return stream;
963}

◆ operator<=()

bool operator<= ( const GncInt128 a,
const GncInt128 b 
)
noexcept

Definition at line 989 of file gnc-int128.cpp.

991{
992 return a.cmp(b) <= 0;
993}

◆ operator==()

bool operator== ( const GncInt128 a,
const GncInt128 b 
)
noexcept

Definition at line 966 of file gnc-int128.cpp.

967{
968 return a.cmp(b) == 0;
969}

◆ operator>()

bool operator> ( const GncInt128 a,
const GncInt128 b 
)
noexcept

Definition at line 984 of file gnc-int128.cpp.

985{
986 return a.cmp(b) > 0;
987}

◆ operator>=()

bool operator>= ( const GncInt128 a,
const GncInt128 b 
)
noexcept

Definition at line 996 of file gnc-int128.cpp.

997{
998 return a.cmp(b) >= 0;
999}

◆ operator>>()

GncInt128 operator>> ( GncInt128  a,
unsigned int  b 
)
noexcept

Definition at line 1064 of file gnc-int128.cpp.

1065{
1066 a >>= b;
1067 return a;
1068}

◆ operator^()

GncInt128 operator^ ( GncInt128  a,
const GncInt128 b 
)
noexcept

Definition at line 1050 of file gnc-int128.cpp.

1051{
1052 a ^= b;
1053 return a;
1054}

◆ operator|()

GncInt128 operator| ( GncInt128  a,
const GncInt128 b 
)
noexcept

Definition at line 1043 of file gnc-int128.cpp.

1044{
1045 a |= b;
1046 return a;
1047}