ToFraction
Converts a number to an approximating rational number.
Syntax
-
ToFraction(x)-
xis a number
-
-
ToFraction(r)-
ris a structure of typeRationalNumber
-
-
ToFraction(a[, [b, ...]])-
a,b,...are the numbers of a continued fraction representation
-
-
ToFraction(L)-
Lis a list containing the numbers of a continued fraction representation
-
Description
-
If
xis a number, thenToFraction(x)is a rational number equal to or very nearly equal tox. -
If
ris a structure of typeRationalNumber, thenToFraction(r)is the rational number thatrrepresents. -
If
a, b, ...is the list of numbers of a continued fraction representation, or ifLis 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)