Main Page   Compound List   File List   Compound Members   File Members  

biginteger Class Reference

#include <biginteger.h>

List of all members.

Public Methods

 biginteger ()
 biginteger (void *raw)
 biginteger (const mpz_t &value_)
 biginteger (int value_)
 biginteger (double value_)
 biginteger (const std::string &value_)
 biginteger (const biginteger &rhs)
biginteger & operator= (const biginteger &rhs)
 ~biginteger ()
void setValue ()
void setValue (mpz_t value_)
const mpz_t & getValueTemp () const
bool isNA () const
std::string str () const
long as_long () const
double as_double () const
int as_raw (void *raw) const
size_t raw_size () const
void swap (biginteger &other)
int isprime (int reps)


Detailed Description

A big integer. Actually a wrapper for mpz_t to work with plus some special stuff.

The biginteger special state "NA" means, no value is assigned. This does not mean, the internal state is not constructed, but the value explicit is "not available".


Constructor & Destructor Documentation

biginteger::biginteger (    )  [inline]
 

Construct a "NA" biginteger.

biginteger::biginteger (  void *    raw ) 
 

Construct a biginteger from a raw expression.

biginteger::biginteger (  const mpz_t &    value_ )  [inline]
 

Create a biginteger from a value. Remember to free the parameter's mpz_t if you allocated them by yourself - biginteger will copy the value.

biginteger::biginteger (  int    value_ )  [inline]
 

Construct a biginteger from a long value.

biginteger::biginteger (  double    value_ )  [inline]
 

Construct a biginteger from a double value.

biginteger::biginteger (  const std::string &    value_ )  [inline]
 

Construct a biginteger from a string value.

biginteger::biginteger (  const biginteger &    rhs )  [inline]
 

Copy constructor (mpz_t aren't standard-copyable)

biginteger::~biginteger (    )  [inline]
 

Free the owned mpz_t structs


Member Function Documentation

double biginteger::as_double (    )  const [inline]
 

Convert the biginteger into a double value (you may loose precision)

long biginteger::as_long (    )  const [inline]
 

Convert the biginteger into a long value (cut off the msb's if it don't fit).

int biginteger::as_raw (  void *    raw )  const
 

Convert the biginteger to a raw memory block. Obtain the size needed from biginteger_raw_size() first and make sure, the buffer provided is large enough to hold the data.

Also remember, that the modulus is not saved this way. To obtain a modulus raw byte use get_modulus().as_raw(void*).

Returns:
number of bytes used (same as raw_size())

const mpz_t& biginteger::getValueTemp (    )  const [inline]
 

For const-purposes, return the value. Remember, that the return value only lives as long as this class live, so do not call getValueTemp on temporary objects.

bool biginteger::isNA (    )  const [inline]
 

Return true, if the value is NA.

int biginteger::isprime (  int    reps )  [inline]
 

Test prime numbers

biginteger& biginteger::operator= (  const biginteger &    rhs )  [inline]
 

Asignment operator.

size_t biginteger::raw_size (    ) 
 

Return the number of bytes needed to store this biginteger in a continous memory block.

void biginteger::setValue (  mpz_t    value_ )  [inline]
 

Set the biginteger to a specific value.

void biginteger::setValue (    )  [inline]
 

Set the biginteger to state "NA".

string biginteger::str (    ) 
 

Convert the biginteger into a standard string.

void biginteger::swap (  biginteger &    other ) 
 

Swap values with the argument


The documentation for this class was generated from the following files:
Generated on Sat Nov 27 18:46:53 2004 for GMP-RCdocumentation by doxygen1.2.18