Crypto++ 8.7
Free C++ class library of cryptographic schemes
|
Multiple precision integer with arithmetic operations. More...
Go to the source code of this file.
Classes | |
struct | InitializeInteger |
Performs static initialization of the Integer class. More... | |
class | Integer |
Multiple precision integer with arithmetic operations. More... | |
class | Integer::DivideByZero |
Exception thrown when division by 0 is encountered. More... | |
class | Integer::RandomNumberNotFound |
Exception thrown when a random number cannot be found that satisfies the condition. More... | |
class | Integer::OpenPGPDecodeErr |
Exception thrown when an error is encountered decoding an OpenPGP integer. More... | |
Typedefs | |
typedef SecBlock< word, AllocatorWithCleanup< word, true > > | IntegerSecBlock |
Functions | |
bool | operator== (const ::Integer &a, const ::Integer &b) |
Comparison. More... | |
bool | operator!= (const ::Integer &a, const ::Integer &b) |
Comparison. More... | |
bool | operator> (const ::Integer &a, const ::Integer &b) |
Comparison. More... | |
bool | operator>= (const ::Integer &a, const ::Integer &b) |
Comparison. More... | |
bool | operator< (const ::Integer &a, const ::Integer &b) |
Comparison. More... | |
bool | operator<= (const ::Integer &a, const ::Integer &b) |
Comparison. More... | |
inline ::Integer | operator+ (const ::Integer &a, const ::Integer &b) |
Addition. More... | |
inline ::Integer | operator- (const ::Integer &a, const ::Integer &b) |
Subtraction. More... | |
inline ::Integer | operator* (const ::Integer &a, const ::Integer &b) |
Multiplication. More... | |
inline ::Integer | operator/ (const ::Integer &a, const ::Integer &b) |
Division. More... | |
inline ::Integer | operator% (const ::Integer &a, const ::Integer &b) |
Remainder. More... | |
inline ::Integer | operator/ (const ::Integer &a, ::word b) |
Division. More... | |
inline ::word | operator% (const ::Integer &a, ::word b) |
Remainder. More... | |
inline ::Integer | operator& (const ::Integer &a, const ::Integer &b) |
Bitwise AND. More... | |
inline ::Integer | operator| (const ::Integer &a, const ::Integer &b) |
Bitwise OR. More... | |
inline ::Integer | operator^ (const ::Integer &a, const ::Integer &b) |
Bitwise XOR. More... | |
void | swap (::Integer &a, ::Integer &b) |
Multiple precision integer with arithmetic operations.
The Integer class can represent positive and negative integers with absolute value less than (256**sizeof(word))(256**sizeof(int)).
Internally, the library uses a sign magnitude representation, and the class has two data members. The first is a IntegerSecBlock (a SecBlock<word>) and it is used to hold the representation. The second is a Sign (an enumeration), and it is used to track the sign of the Integer.
For details on how the Integer class initializes its function pointers using InitializeInteger and how it creates Integer::Zero(), Integer::One(), and Integer::Two(), then see the comments at the top of integer.cpp
.
Definition in file integer.h.
typedef SecBlock<word, AllocatorWithCleanup<word, true> > IntegerSecBlock |
Bitwise AND.
operator&() performs a bitwise AND on the operands. Missing bits are truncated at the most significant bit positions, so the result is as small as the smaller of the operands.
Internally, Crypto++ uses a sign-magnitude representation. The library does not attempt to interpret bits, and the result is always POSITIVE. If needed, the integer should be converted to a 2's compliment representation before performing the operation.
Bitwise OR.
operator|() performs a bitwise OR on the operands. Missing bits are shifted in at the most significant bit positions, so the result is as large as the larger of the operands.
Internally, Crypto++ uses a sign-magnitude representation. The library does not attempt to interpret bits, and the result is always POSITIVE. If needed, the integer should be converted to a 2's compliment representation before performing the operation.
Bitwise XOR.
operator^() performs a bitwise XOR on the operands. Missing bits are shifted in at the most significant bit positions, so the result is as large as the larger of the operands.
Internally, Crypto++ uses a sign-magnitude representation. The library does not attempt to interpret bits, and the result is always POSITIVE. If needed, the integer should be converted to a 2's compliment representation before performing the operation.