ToFraction
Converts a number to an approximating rational number.
Syntax

ToFraction(x)

x
is a number


ToFraction(r)

r
is a structure of typeRationalNumber


ToFraction(a[, [b, ...]])

a
,b
,...
are the numbers of a continued fraction representation


ToFraction(L)

L
is a list containing the numbers of a continued fraction representation

Description

If
x
is a number, thenToFraction(x)
is a rational number equal to or very nearly equal tox
. 
If
r
is a structure of typeRationalNumber
, thenToFraction(r)
is the rational number thatr
represents. 
If
a, b, ...
is the list of numbers of a continued fraction representation, or ifL
is a list with these numbers, thenToFraction(a, b, ...)
andToFraction(L)
both return the rational number that the continued fraction represents.
Examples
ToFraction(5.72)
143/25 (=5.72)
ToFraction(π)
2549491779/811528438 (=3.14159265359)
ToFraction(5, 1, 2, 1, 1, 3)
143/25 (=5.72)