# Rational approximation: float2rational exact

### 5.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 2.5.7, item 9).

#### Examples.

- Input:
  float2rational(1.5)
  Output:

  3
  2

- Input:
  float2rational(1.414)
  Output:

  707
  500

- Input:
  float2rational(0.156381102937*2)
  Output:

  5144
  16447

- Input:
  float2rational(1.41421356237)
  Output:

  114243
  80782

  Input:
  float2rational(1.41421356237^2)
  Output:

  2