Algorithmic Solutions > LEDA > LEDA Guide > Number Types > Big Floatingpoint Numbers

Big Floatingpoint Numbers

The data type bigfloat can be used to represent floating point numbers with arbitrary precision. Floating point numbers approximate mathematics' real numbers.

Remark: In contrast to Algebraic Real Numbers, computations based on Big Floating Point Numbers are not performed exactly. Like for the built-in types float and double, the results of the arithmetic operations are rounded. However, in contrast to double the rounding precision can be arbitrary large.

Example

The following program shows how to use bigfloat. It creates two bigfloats bf1 and bf2, and initializes them with 3.1314 and 23*2117, respectively. Then it computes the bigfloat bf3 as bf11/3 with relative error <= 2-10.
#include <LEDA/numbers/bigfloat.h>

using namespace leda;

int main()
{
  bigfloat bf1=3.1414;
  bigfloat bf2(23,117);
  bigfloat bf3=sqrt_d(bf1,10,3);

  std::cout << "bf1=" << bf1 << std::endl;
  std::cout << "bf2=" << bf2 << std::endl;
  std::cout << "bf3=" << bf3 << std::endl;

  return 0;
}

Strengths

  • arbitrary precision instead of single (float), respectively double (double), precision
  • can be used like double and together with built-in number types
  • special values +/- 0, +/- infinity, and NaN (=not a number) defined
  • different rounding modes available
  • different arithmetic operations predefined

Disadvantages

  • about 60-200 times slower than double depending on chosen rounding precision
  • quite difficult to use

Tips

Big Floating Point Numbers have many interesting features, but are quite difficult to use. They are mainly intended for advanced users.

See also:

Integers of Arbitrary Length

Algebraic Real Numbers

Rational Numbers

Floating Point Filter

Interval Arithmetic


Vectors and Matrices with Integer Entries

Vectors and Matrices with Double Entries

Rational Vectors

Functions of numerical analysis


Manual Entries:

Manual Page Big Floatingpoint Numbers




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH