Nat Class Reference

#include <pk.h>


Detailed Description

Data type used to represent elements of various algebraic objects.


Public Types

typedef Nat const & cNat
 const reference to a Nat

Public Member Functions

Inspectors
int bit (int k) const
 Get k-th bit of this object.
int degree () const
 Get length of this object in bits.
int length () const
 Get length of this object in nwords.
Arithmetic and Logical Operations
void add1 (cnat y)
 Add number to this one.
void sub1 (cnat y)
 Subtract number from this one.
void subr (cnwordp a)
 Subtract this object from another.
void extend (int n)
 Extend length of this object by specified number of nwords.
void shiftright (int k=1)
 Right shift this object by a specified number of bits.
void shiftleft (int k=1)
 Left shift this object by a specified number of bits.
void xorshift (int k, cnat a)
 Left shift number and XOR into this object.
Assignment and Arithmetic Operators
Natoperator= (nword x)
 Assignment operator.
Natoperator= (const Nat &x)
 Assignment operator.
void operator+= (cnat y)
 Increment this object by a specified amount.
void operator-= (cnat y)
 Decrement this object by a specified amount.
Predicates
bool isOdd () const
 Predicate to test oddness.
bool isEven () const
 Predicate to test evenness.
bool operator== (nword n) const
 Predicate to test equality of natural numbers.
bool operator!= (nword n) const
 Predicate to test inequality of natural numbers.
bool operator== (cNat x) const
 Predicate to test equality of Nat objects.
bool operator!= (cNat x) const
 Predicate to test inequality of Nat objects.
bool operator<= (cNat x) const
 Predicate to test "less than or equal to" relation between Nat objects.
bool operator>= (cNat x) const
 Predicate to test "greater than or equal to" relation between Nat objects.
bool operator< (cNat x) const
 Predicate to test "less than" relation between Nat objects.
bool operator> (cNat x) const
 Predicate to test "greater than" relation between Nat objects.


Member Function Documentation

void add1 ( cnat  y  ) 

Add number to this one.

Parameters:
y object to add to this object

int bit ( int  k  )  const

Get k-th bit of this object.

Parameters:
k index of bit to return
Returns:
k-th bit of the natural number represented by this object

int degree (  )  const

Get length of this object in bits.

Returns:
log2(x)

void extend ( int  n  ) 

Extend length of this object by specified number of nwords.

Parameters:
n new size of object in nwords.
Remarks:
Modifies: w is padded with zeros so len >= n

bool isEven (  )  const [inline]

Predicate to test evenness.

Returns:
true, if the number stored in this object is even
false otherwise

bool isOdd (  )  const [inline]

Predicate to test oddness.

Returns:
true, if the number stored in this object is odd
false, otherwise.

int length (  )  const [inline]

Get length of this object in nwords.

Returns:
len (i.e., number of nwords are used by this object)

bool operator!= ( cNat  x  )  const [inline]

Predicate to test inequality of Nat objects.

Parameters:
x Nat object to which this one is to be compared
Returns:
true, if x != this
false, if x == this

bool operator!= ( nword  n  )  const [inline]

Predicate to test inequality of natural numbers.

Parameters:
n nword to compare with this object.
Returns:
true, if this object does not equal n
false, if they are equal

void operator+= ( cnat  y  ) 

Increment this object by a specified amount.

Parameters:
y the number to add to this object

void operator-= ( cnat  y  )  [inline]

Decrement this object by a specified amount.

Parameters:
y number to be sutracted from this object

bool operator< ( cNat  x  )  const [inline]

Predicate to test "less than" relation between Nat objects.

Parameters:
x Nat object to which this one is to be compared
Returns:
true, if x < this
false, otherwise

bool operator<= ( cNat  x  )  const [inline]

Predicate to test "less than or equal to" relation between Nat objects.

Parameters:
x Nat object to which this one is to be compared
Returns:
true, if x <= this
false, otherwise

Nat& operator= ( const Nat x  ) 

Assignment operator.

Parameters:
x Nat to assign to this object
Returns:
a reference to this object
Remarks:
Modifies: w (x.w is copied into this.w).

Warning: this.len *must* be >= x.len

Nat& operator= ( nword  x  ) 

Assignment operator.

Parameters:
x nword to assign to this object
Returns:
a reference to this object
Remarks:
Modifies: w (this object becomes a Nat with len = 1)

bool operator== ( cNat  x  )  const [inline]

Predicate to test equality of Nat objects.

Parameters:
x Nat object to which this one is to be compared
Returns:
true, if x == this
false, if x != this

bool operator== ( nword  n  )  const

Predicate to test equality of natural numbers.

Parameters:
n nword to compare with this object.
Returns:
true, if this object equals n
false, if they are unequal

bool operator> ( cNat  x  )  const [inline]

Predicate to test "greater than" relation between Nat objects.

Parameters:
x Nat object to which this one is to be compared
Returns:
true, if x > this
false, otherwise

bool operator>= ( cNat  x  )  const [inline]

Predicate to test "greater than or equal to" relation between Nat objects.

Parameters:
x Nat object to which this one is to be compared
Returns:
true, if x >= this
false otherwise

void shiftleft ( int  k = 1  ) 

Left shift this object by a specified number of bits.

Parameters:
k number of bits to left shift this object.

void shiftright ( int  k = 1  ) 

Right shift this object by a specified number of bits.

Parameters:
k number of bits to right shift this object.

void sub1 ( cnat  y  ) 

Subtract number from this one.

Parameters:
y object to subtract from this object

void subr ( cnwordp  a  ) 

Subtract this object from another.

Parameters:
a object from which to subtract this object
Remarks:
Modifies: w = a - this.w

void xorshift ( int  k,
cnat  a 
)

Left shift number and XOR into this object.

Parameters:
k number of bits to leftshift a
a number to XOR with this Modifies: w (this gets the result of this XOR'd with a left shifted k bits).


The documentation for this class was generated from the following file:
ISC Cryptographic Development Kit - User's Guide
ISC website
Questions? E-mail ISC technical support
Copyright© 2002-2006 Information Security Corp. All rights reserved.