Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

# BigTypes.h File Reference

Provide Big Integer class. More...

`#include "Types.h"`

## Namespaces
namespace | big
## Defines
#define | BIGHIGHBIT(n) ((n)[sizeof(n) / sizeof(big::word) - 1] & WORDHIGHBIT)
#define | BIGONETYPE template<class T>
#define | BIGTWOTYPES template<class T, class Bigger>
#define | BIGSMALLTYPE template<class Smaller>
#define | BIGWORDCOUNT_FROMBITCOUNT(bits) ((bits) / 8 / sizeof(big::word))
#define | BIGWORDCOUNT(T) (sizeof(T) / sizeof(big::word))
#define | BIGBITCOUNT(T) (sizeof(T) * 8)
#define | BIGDOUBLESIZE(T, var_name) big::word (var_name)[BIGWORDCOUNT(T) * 2]
#define | BIGHALFSIZE(T, var_name) big::word (var_name)[BIGWORDCOUNT(T) / 2]
#define | BIGINTFAST INLINE Int<T> &
#define | BIGINTSLOW Int<T>
## Typedefs
typedef u32 | word
typedef word | u128 [BIGWORDCOUNT_FROMBITCOUNT(128)]
typedef word | u256 [BIGWORDCOUNT_FROMBITCOUNT(256)]
typedef word | u512 [BIGWORDCOUNT_FROMBITCOUNT(512)]
typedef word | u1024 [BIGWORDCOUNT_FROMBITCOUNT(1024)]
typedef word | u2048 [BIGWORDCOUNT_FROMBITCOUNT(2048)]
typedef word | u4096 [BIGWORDCOUNT_FROMBITCOUNT(4096)]
typedef word | u8192 [BIGWORDCOUNT_FROMBITCOUNT(8192)]
typedef word | u16384 [BIGWORDCOUNT_FROMBITCOUNT(16384)]
typedef word | u32768 [BIGWORDCOUNT_FROMBITCOUNT(32768)]
## Functions
BIGONETYPE INLINE void | zero (T &n)
BIGONETYPE INLINE void | usetw (T &a, word b)
BIGONETYPE INLINE void | ssetw (T &a, word b)
BIGONETYPE INLINE void | set (T &a, T &b)
BIGTWOTYPES INLINE void | usetlow (Bigger &a, T &b)
BIGTWOTYPES INLINE void | ssetlow (Bigger &a, T &b)
BIGTWOTYPES INLINE void | sethigh (Bigger &a, T &b)
BIGTWOTYPES INLINE void | takelow (T &a, Bigger &b)
BIGTWOTYPES INLINE void | takehigh (T &a, Bigger &b)
BIGONETYPE bool | ugreater (T &a, T &b)
BIGONETYPE bool | ugreaterOrEqual (T &a, T &b)
BIGONETYPE bool | sgreater (T &a, T &b)
BIGONETYPE bool | sgreaterOrEqual (T &a, T &b)
BIGONETYPE INLINE bool | equal (T &a, T &b)
BIGONETYPE INLINE bool | isZero (T &n)
BIGONETYPE void | bAND (T &a, T &b)
BIGONETYPE void | bOR (T &a, T &b)
BIGONETYPE void | bXOR (T &a, T &b)
BIGONETYPE void | bNOT (T &n)
BIGONETYPE void | shiftLeft1 (T &n)
BIGONETYPE void | shiftLeft (T &n, u32 s)
BIGONETYPE void | ushiftRight1 (T &n)
BIGONETYPE void | ushiftRight (T &n, u32 s)
BIGONETYPE void | sshiftRight1 (T &n)
BIGONETYPE void | sshiftRight (T &n, u32 s)
BIGONETYPE void | add (T &a, T &b)
BIGONETYPE void | increment (T &n)
BIGONETYPE void | subtract (T &a, T &b)
BIGONETYPE void | decrement (T &n)
BIGONETYPE void | negate (T &n)
BIGONETYPE void | usquare (T &a)
BIGTWOTYPES void | umultiply (T &a, T &b, Bigger &m)
BIGTWOTYPES void | umultiply (Bigger &a, T &b)
BIGONETYPE void | ssquare (T &a)
BIGTWOTYPES void | smultiply (T &a, T &b, Bigger &m)
BIGTWOTYPES void | smultiply (Bigger &a, T &b)
BIGONETYPE void | udivide (T &a, T &b, T &q, T &r)
BIGONETYPE void | umodulo (T &a, T &b, T &r)
BIGONETYPE void | sdivide (T &a, T &b, T &q, T &r)
BIGONETYPE void | smodulo (T &a, T &b, T &r)
## Variables
const u32 | WORDBITS = sizeof( word ) * 8
const u32 | HALFWORDBITS = sizeof( word ) * 8 / 2
const word | WORDHIGHBIT = ( word ) 1 << ( WORDBITS - 1 )
const word | WORDALLBITS = ( word ) 0 - 1
const word | WORDLOBITS = ( ( word ) 1 << HALFWORDBITS ) - 1
const word | WORDHIBITS = WORDALLBITS ^ WORDLOBITS

## Detailed Description

Provide Big Integer class.

(128)2^7-bit to (32768)2^14-bit signed 2's complement & unsigned extended arithmetic

catid(cat02e@fsu.edu)

7/30/2004 Fixed VS6 compat 7/28/2004 Fixed macros so they can be used outside of the big namespace Now using pre-processor definitions from types.h for inline assembly 7/26/2004 Removed a lot of assembly, made add/sub assembly optional 7/25/2004 Merged the wrapper class Int<T> from older code 7/24/2004 Replaced trivial assembly code with std:: functions Refined some assembly code with Art of Assembly chapter 9 Added binary ops 7/23/2004 Finished assembly coding Removed Int<T> class, for now Added old C++ code back in with USEASSEMBLY 7/22/2004 Signed arithmetic (needed for ext. Euclidean algo) Cleaned up coding style Began rewriting parts in assembly 7/21/2004 Began writing

Tabs: 4 spaces Dist: public

## Define Documentation

#define BIGBITCOUNT | ( | T |  | ) | (sizeof(T) * 8)

#define BIGDOUBLESIZE | ( | T,
|  | var_name |  | ) | big::word (var_name)[BIGWORDCOUNT(T) * 2]

#define BIGHALFSIZE | ( | T,
|  | var_name |  | ) | big::word (var_name)[BIGWORDCOUNT(T) / 2]

#define BIGHIGHBIT | ( | n |  | ) | ((n)[sizeof(n) / sizeof(big::word) - 1] & WORDHIGHBIT)

#define BIGINTFAST INLINE Int<T> &

#define BIGINTSLOW Int<T>

#define BIGONETYPE template<class T>

#define BIGSMALLTYPE template<class Smaller>

#define BIGTWOTYPES template<class T, class Bigger>

#define BIGWORDCOUNT | ( | T |  | ) | (sizeof(T) / sizeof(big::word))

#define BIGWORDCOUNT_FROMBITCOUNT | ( | bits |  | ) | ((bits) / 8 / sizeof(big::word))

## Typedef Documentation

typedef word big::u1024[BIGWORDCOUNT_FROMBITCOUNT(1024)]

typedef word big::u128[BIGWORDCOUNT_FROMBITCOUNT(128)]

typedef word big::u16384[BIGWORDCOUNT_FROMBITCOUNT(16384)]

typedef word big::u2048[BIGWORDCOUNT_FROMBITCOUNT(2048)]

typedef word big::u256[BIGWORDCOUNT_FROMBITCOUNT(256)]

typedef word big::u32768[BIGWORDCOUNT_FROMBITCOUNT(32768)]

typedef word big::u4096[BIGWORDCOUNT_FROMBITCOUNT(4096)]

typedef word big::u512[BIGWORDCOUNT_FROMBITCOUNT(512)]

typedef word big::u8192[BIGWORDCOUNT_FROMBITCOUNT(8192)]

typedef u32 big::word

## Function Documentation

BIGONETYPE void big::add | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE void big::bAND | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE void big::bNOT | ( | T & | n | ) |

BIGONETYPE void big::bOR | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE void big::bXOR | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE void big::decrement | ( | T & | n | ) |

BIGONETYPE INLINE bool big::equal | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE void big::increment | ( | T & | n | ) |

BIGONETYPE INLINE bool big::isZero | ( | T & | n | ) |

BIGONETYPE void big::negate | ( | T & | n | ) |

BIGONETYPE void big::sdivide | ( | T & | a,
|  | T & | b,
|  | T & | q,
|  | T & | r
| ) |

BIGONETYPE INLINE void big::set | ( | T & | a,
|  | T & | b
| ) |

BIGTWOTYPES INLINE void big::sethigh | ( | Bigger & | a,
|  | T & | b
| ) |

BIGONETYPE bool big::sgreater | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE bool big::sgreaterOrEqual | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE void big::shiftLeft | ( | T & | n,
|  | u32 | s
| ) |

BIGONETYPE void big::shiftLeft1 | ( | T & | n | ) |

BIGONETYPE void big::smodulo | ( | T & | a,
|  | T & | b,
|  | T & | r
| ) |

BIGTWOTYPES void big::smultiply | ( | Bigger & | a,
|  | T & | b
| ) |

BIGTWOTYPES void big::smultiply | ( | T & | a,
|  | T & | b,
|  | Bigger & | m
| ) |

BIGTWOTYPES INLINE void big::ssetlow | ( | Bigger & | a,
|  | T & | b
| ) |

BIGONETYPE INLINE void big::ssetw | ( | T & | a,
|  | word | b
| ) |

BIGONETYPE void big::sshiftRight | ( | T & | n,
|  | u32 | s
| ) |

BIGONETYPE void big::sshiftRight1 | ( | T & | n | ) |

BIGONETYPE void big::ssquare | ( | T & | a | ) |

BIGONETYPE void big::subtract | ( | T & | a,
|  | T & | b
| ) |

BIGTWOTYPES INLINE void big::takehigh | ( | T & | a,
|  | Bigger & | b
| ) |

BIGTWOTYPES INLINE void big::takelow | ( | T & | a,
|  | Bigger & | b
| ) |

BIGONETYPE void big::udivide | ( | T & | a,
|  | T & | b,
|  | T & | q,
|  | T & | r
| ) |

BIGONETYPE bool big::ugreater | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE bool big::ugreaterOrEqual | ( | T & | a,
|  | T & | b
| ) |

BIGONETYPE void big::umodulo | ( | T & | a,
|  | T & | b,
|  | T & | r
| ) |

BIGTWOTYPES void big::umultiply | ( | Bigger & | a,
|  | T & | b
| ) |

BIGTWOTYPES void big::umultiply | ( | T & | a,
|  | T & | b,
|  | Bigger & | m
| ) |

BIGTWOTYPES INLINE void big::usetlow | ( | Bigger & | a,
|  | T & | b
| ) |

BIGONETYPE INLINE void big::usetw | ( | T & | a,
|  | word | b
| ) |

BIGONETYPE void big::ushiftRight | ( | T & | n,
|  | u32 | s
| ) |

BIGONETYPE void big::ushiftRight1 | ( | T & | n | ) |

BIGONETYPE void big::usquare | ( | T & | a | ) |

BIGONETYPE INLINE void big::zero | ( | T & | n | ) |

## Variable Documentation

const u32 big::HALFWORDBITS = sizeof( word ) * 8 / 2

const word big::WORDALLBITS = ( word ) 0 - 1

const u32 big::WORDBITS = sizeof( word ) * 8

const word big::WORDHIBITS = WORDALLBITS ^ WORDLOBITS

const word big::WORDHIGHBIT = ( word ) 1 << ( WORDBITS - 1 )

const word big::WORDLOBITS = ( ( word ) 1 << HALFWORDBITS ) - 1