manpagez: man pages & more
info cln
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.11.2 Conversion to rational numbers

Each of the classes cl_R, cl_RA, cl_F defines the following operation:

cl_RA rational (const type& x)

Returns the value of x as an exact number. If x is already an exact number, this is x. If x is a floating-point number, the value is a rational number whose denominator is a power of 2.

In order to convert back, say, (cl_F)(cl_R)"1/3" to 1/3, there is the function

cl_RA rationalize (const cl_R& x)

If x is a floating-point number, it actually represents an interval of real numbers, and this function returns the rational number with smallest denominator (and smallest numerator, in magnitude) which lies in this interval. If x is already an exact number, this function returns x.

If x is any float, one has


This document was generated on August 27, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.