y-cruncher Multi-Precision Library

A Multi-threaded Multi-Precision Arithmetic Library

(Powered by y-cruncher)

(Last updated: March 3, 2016)

 

Shortcuts:

YMP Library:

Large Number Objects:

Low-Level Programming:

BigFloat - Large Floating-Point

 

BigFloat is a large floating-point object:

 

Types:

 

BigFloat is an abstract base class for BigFloatR and BigFloatO. So it cannot be used directly.

These subclasses differ in only their resource ownership policies. But otherwise, they have nearly identical functionality.

 

 

Representation:

 

The current representation of the BigFloat object is as follows:

BigFloat = sign * ( A[0] + A[1]*base1 + A[2]*base2 + A[3]*base3 + ... ) * baseexp

with the following relevant fields:

 

Function List:

 

Being the abstract base class, there isn't much functionality here.

 

Const Getters:

 

Getters:

 

Get Array Pointer:

const u32_t* BigFloat<u32_t>::get_T () const;

const u64_t* BigFloat<u64_t>::get_T () const;

 

Returns a pointer to the start of the internal array.

Get Length:

upL_t BigFloat<u32_t>::get_L () const;

upL_t BigFloat<u64_t>::get_L () const;

 

Return the logical length of the array. (the mantissa)

Get Exponent:

siL_t BigFloat<u32_t>::get_exp () const;

siL_t BigFloat<u64_t>::get_exp () const;

 

Return the exponent.

If the object has a value of zero, the returned value is undefined.

Get Magnitude:

siL_t BigFloat<u32_t>::get_mag () const;

siL_t BigFloat<u64_t>::get_mag () const;

 

Return the magnitude of the object. The magnitude is defined as the smallest power of the base that is larger in magnitude than the object.

If the object has a value of zero, the returned value is undefined.

 

Mathematically:

magnitude = Floor( Logbase( Abs(this) ) ) + 1

Internally: get_mag() = get_exp() + get_L().

Get Sign:

int BigFloat<u32_t>::get_sign () const;

int BigFloat<u64_t>::get_sign () const;

 

Returns:

Get Buffer Size:

upL_t BigFloat<u32_t>::get_buffersize () const;

upL_t BigFloat<u64_t>::get_buffersize () const;

 

Returns the size of the internal buffer. This gives the largest number (in words) that can be stored in the object.

 


Convert to Double-Precision:

double BigFloat<u32_t>::to_double (siL_t& exp) const;

double BigFloat<u64_t>::to_double (siL_t& exp) const;

Description:

Converts the current object to double-precision. The exponent is stored into exp. This exponent is there to avoid overflow.

this = (return value) * baseexp

 


Is Zero:

bool BigFloat<u32_t>::is_zero () const;

bool BigFloat<u64_t>::is_zero () const;

Description:

Returns true if the current object is zero.

 


Operator[]:

u32_t BigFloat<u32_t>::operator[] (siL_t mag) const;

u64_t BigFloat<u64_t>::operator[] (siL_t mag) const;

Description:

Returns the word at the specified magnitude.

 

Mathematically:

(return value) = Floor( Abs(this) / basemag ) mod base

 


Get Range:

void BigFloat<u32_t>::get_range (u32_t* buffer, siL_t s, upL_t L) const;

void BigFloat<u64_t>::get_range (u64_t* buffer, siL_t s, upL_t L) const;

Description:

Get the words in the range [s, s + L) and write them to buffer. This is a multi-word version of operator[].

 

Mathematically:

{buffer, L} = Floor( Abs(this) / bases ) mod baseL

 


Compare:

bool operator< (const BigFloat<u32_t>& A, const BigFloat<u32_t>& B);

bool operator< (const BigFloat<u64_t>& A, const BigFloat<u64_t>& B);

 

bool operator> (const BigFloat<u32_t>& A, const BigFloat<u32_t>& B);

bool operator> (const BigFloat<u64_t>& A, const BigFloat<u64_t>& B);

 

bool operator<= (const BigFloat<u32_t>& A, const BigFloat<u32_t>& B);

bool operator<= (const BigFloat<u64_t>& A, const BigFloat<u64_t>& B);

 

bool operator>= (const BigFloat<u32_t>& A, const BigFloat<u32_t>& B);

bool operator>= (const BigFloat<u64_t>& A, const BigFloat<u64_t>& B);

 

bool operator== (const BigFloat<u32_t>& A, const BigFloat<u32_t>& B);

bool operator== (const BigFloat<u64_t>& A, const BigFloat<u64_t>& B);

 

int BigFloat<u32_t>::cmp (const BigFloat<u32_t>& B) const;

int BigFloat<u64_t>::cmp (const BigFloat<u64_t>& B) const;

Description:

Standard comparison operators.

 

cmp() returns:

 


Incremental Scratch Buffer Size:

static uiL_t BigFloat<u32_t>::iPsize (uiL_t p, upL_t tds = 1);

static uiL_t BigFloat<u64_t>::iPsize (uiL_t p, upL_t tds = 1);

Description:

Similar to mul_iPsize().

 

Returns the size of the scratch buffer needed to call any large multiplication on a BigFloat object with a precision of at most p and using a task decomposition of at most tds.

 

This is mainly used for populating the BasicParameters object.