Algorithmic Solutions > LEDA > LEDA Guide > Number Types > Algebraic Real Numbers

Algebraic Real Numbers

The data type real approximates mathematics' real numbers. It is LEDA's most powerful number type.


The following program shows a computation where the exact real arithmetic evaluates to zero in contrast to floating point arithmetic. Notice that the explicit cast of the numbers 12 and 17 is really necessary, here. Otherwise the right hand side is evaluated with double arithmetic.
#include <LEDA/numbers/real.h>

using namespace leda;

int main()
  real x;
  if (x==0) std::cout << "x==0\n";
  else std::cout << "x!=0\n";

  double xd;
  if (xd==0) std::cout << "xd==0\n";
  else std::cout << "xd!=0\n";

  return 0;


  • computations with reals always yield mathematically correct results
  • can be used like double and together with built-in number types
  • many powerful arithmetic operations predefined, like square roots and k-th roots
  • efficient implementation


  • space grows linearly with the size of a computation (all operations of a computation are recorded)
  • about 10-80 times slower than double
  • in general less efficient than Integers of Arbitrary Length and Rational Numbers. (This disadvantage is partially offset by filtering mechanisms.)


Use reals to do exact computations with square roots and k-th roots. Otherwise consider using Big Floatingpoint Numbers.

See also:

Integers of Arbitrary Length

Rational Numbers

Big Floatingpoint 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 Algebraic Real Numbers


Please send any suggestions, comments or questions to
© Copyright 2001-2003, Algorithmic Solutions Software GmbH