![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <cUInt64.h>
Public Types | |
typedef UINT64 | UNIT_t |
Public Member Functions | |
cUInt64 () | |
cUInt64 (UNIT_t n) | |
cUInt64 (const char *pszVal, RADIX_t n=10) | |
bool | isZero () const |
bool | isOdd () const |
bool | IsSet (BIT_ENUM_t nBit) const |
bool | operator== (const cUInt64 &n) const |
bool | operator!= (const cUInt64 &n) const |
bool | operator== (UNIT_t n) const |
bool | operator> (const cUInt64 &n) const |
bool | operator< (const cUInt64 &n) const |
bool | operator<= (const cUInt64 &n) const |
template<typename TYPE > | |
TYPE | get_Val () const |
void | operator++ () |
void | operator++ (int) |
void | operator-- () |
void | operator-- (int) |
cUInt64 & | operator+= (const cUInt64 &n) |
cUInt64 & | operator-= (const cUInt64 &n) |
cUInt64 & | operator*= (const cUInt64 &x) |
cUInt64 | operator* (const cUInt64 &x) const |
void | operator%= (const cUInt64 &x) |
void | SetBit (BIT_ENUM_t uiBit) |
cUInt64 & | operator|= (const cUInt64 &n) |
cUInt64 & | operator&= (const cUInt64 &n) |
cUInt64 & | operator^= (const cUInt64 &n) |
cUInt64 & | operator<<= (BIT_ENUM_t uiBits) |
cUInt64 & | operator>>= (BIT_ENUM_t uiBits) |
StrLen_t | GetStr (char *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix=10) const |
cString | GetStr (RADIX_t nBaseRadix=10) const |
bool | SetStr (const char *pszVal, RADIX_t nBaseRadix=10, const char **ppszEnd=(const char **) nullptr) |
BIT_ENUM_t | get_Highest1Bit () const |
HRESULT | SetRandomBits (BIT_ENUM_t nBits) |
void | SetPowerMod (const cUInt64 &base, const cUInt64 &exponent, const cUInt64 &modulus) |
bool | isPrime () const |
int | SetRandomPrime (BIT_ENUM_t nBits, cThreadState *pCancel=nullptr) |
void | OpBitShiftLeft1 (UNIT_t nBitMask) |
Static Public Member Functions | |
static void __stdcall | Divide (const cUInt64 ÷nd, const cUInt64 &divisor, OUT cUInt64 "ient, OUT cUInt64 &remainder) |
static void __stdcall | EuclideanAlgorithm (const cUInt64 &x, const cUInt64 &y, OUT cUInt64 &a, OUT cUInt64 &b, OUT cUInt64 &g) |
Static Public Attributes | |
static const unsigned | k_UNIT_BITS = 64 |
Friends | |
class | cUInt64Tests |
emulate 64 bit unsigned integer as a native type for systems that don't actually support this. QWord if ! USE_INT64 then ASSUME we DONT support 64 bit int types natively. Assume all platforms support 32 bit types. we don't support __int64 (_MSC_VER) or int64_t (C99/GCC standard) native. like cUnion64 or LARGE_INTEGER as a native type for operators. same size as UINT64 use typedef cUInt64 UINT64; if ! USE_INT64
typedef UINT64 Gray::cUInt64::UNIT_t |
|
inline |
|
inline |
|
inline |
|
static |
Division with remainder get quotient,remainder for dividend/divisor.
|
static |
This function uses the Euclidean algorithm to find the greatest common divisor g of the positive integers x and y and also two integers a and b such that ax - by = g, 1 <= a <= y and 0 <= b < x.
This function will fail in undefined ways if either x or y is zero.
BIT_ENUM_t Gray::cUInt64::get_Highest1Bit | ( | ) | const |
|
inline |
just default to assume TYPE is unsigned.
encode value as string.
|
inline |
bool Gray::cUInt64::isPrime | ( | ) | const |
This function uses Fermat's (little) Theorem 100 times to test the primeness of a (large) positive integer. if p is prime then for any integer x, ( x^p - x ) will be evenly divisible by p. Small Primes: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 http://en.wikipedia.org/wiki/Primality_test
|
inline |
Gets the state of the enumerated bit. which has value 2^nBit. Bits beyond m_nBlksUse are considered to be 0.
|
inline |
void Gray::cUInt64::OpBitShiftLeft1 | ( | UNIT_t | nBitMask | ) |
|
inline |
Modulus *this by x.
|
inline |
|
inline |
Post fix increment: same as prefix
|
inline |
|
inline |
Postfix decrement: same as prefix
|
inline |
|
inline |
|
inline |
void Gray::cUInt64::SetPowerMod | ( | const cUInt64 & | base, |
const cUInt64 & | exponent, | ||
const cUInt64 & | modulus | ||
) |
Set *this to 'base' to the power of 'exponent' then modulus. *this = ((base^exponent)modulus)
HRESULT Gray::cUInt64::SetRandomBits | ( | BIT_ENUM_t | nBits | ) |
int Gray::cUInt64::SetRandomPrime | ( | BIT_ENUM_t | nBits, |
cThreadState * | pCancel = nullptr |
||
) |
This function generates/finds/guesses a random prime.
bool Gray::cUInt64::SetStr | ( | const char * | pszVal, |
RADIX_t | nBaseRadix = 10 , |
||
const char ** | ppszEnd = (const char**) nullptr |
||
) |
|
friend |
|
static |