CGAL 5.4.4 - Number Types
Relates Rational

Classes

class  CGAL::Rational_traits< NT >
 The class Rational_traits can be used to determine the type of the numerator and denominator of a rational number type as Quotient, Gmpq, mpq_class or leda_rational. More...
 

Functions

template<typename Rational >
Rational CGAL::simplest_rational_in_interval (double d1, double d2)
 computes the rational number with the smallest denominator in the interval [d1,d2]. More...
 
template<typename Rational >
Rational CGAL::to_rational (double d)
 computes the rational number that equals d. More...
 

Function Documentation

◆ simplest_rational_in_interval()

template<typename Rational >
Rational CGAL::simplest_rational_in_interval ( double  d1,
double  d2 
)

#include <CGAL/simplest_rational_in_interval.h>

computes the rational number with the smallest denominator in the interval [d1,d2].

Computes the simplest rational number in an interval of two double values.

Implementation

See Knuth, "Seminumerical algorithms", page 654, answer to exercise 4.53-39.

See also
CGAL::to_rational()

◆ to_rational()

template<typename Rational >
Rational CGAL::to_rational ( double  d)

#include <CGAL/to_rational.h>

computes the rational number that equals d.

Computes the rational number representing a given double precision floating point number.

See also
CGAL::simplest_rational_in_interval()