convert/rational
convert float to an approximate rational
Calling Sequence
Parameters
Description
Examples
convert(float, rational, digits)
convert(float, fraction, digits)
float
-
floating-point number
digits
(optional) integer or the name exact
The convert/rational function converts a floating-point number to an approximate rational number. The meaning of the type fraction is identical with rational in this context.
The accuracy of the conversion will depend on the value of the global variable Digits, or the value of digits if specified as an integer.
If the third argument digits is the name 'exact' then an exact conversion of float to a rational will be performed; thus Float(f, e) becomes simply f*10^e. Note that exact conversion executes much more quickly than the more sophisticated conversion.
Note: See also the identify command to find a closed form for a decimal approximation of a number.
convert⁡0.125,rational
18
convert⁡2.345,rational
469200
convert⁡0.3333333333,rational
13
convert⁡0.3333333333,rational,exact
333333333310000000000
convert⁡evalf⁡π,rational
10434833215
convert⁡evalf⁡π,rational,3
227
convert⁡evalf⁡π,rational,exact
1570796327500000000
See Also
convert
Digits
Download Help Document