6.59.7 Rational approximation: float2rational exact
Floating point numbers are considered approximations, while integers
and rational numbers are considered exact. The
float2rational command finds a rational approximation to
a floating point number.
exact is a synonym for float2rational.
-
float2rational takes one argument:
expr, an expression.
- float2rational(expr) returns
expr with all the floating point numbers in expr
replaced by rational numbers; any floating point number x is
replaced by a rational r with |r−x|<є, where є
is given by epsilon in the cas configuration
(see Section 3.5.7, item 9).
Examples.
-
Input:
float2rational(1.5)
Output:
- Input:
float2rational(1.414)
Output:
- Input:
float2rational(0.156381102937*2)
Output:
- Input:
float2rational(1.41421356237)
Output:
Input:
float2rational(1.41421356237^2)
Output: