FractionParts
Returns the numerator and denominator of a rational number written in its irreducible form.
Syntax
-
FractionParts(r)-
ris a rational number
-
Description
If r = p/q is a rational number with p and q > 0 relatively prime integers, then FractionParts(r) returns a structure of type RationalNumber with members numerator: p and denominator: q.
If x is a real number, an attempt is made to find a rational approximation of it. However, if you only need to see this approximation, it is better to obtain it as a rational number using the ToFraction function instead of obtaining it as a structure using FractionParts.
A structure of type RationalNumber can be converted to the corresponding rational number using the ToFraction function.
Examples
FractionParts(6.2256)
numerator: 3891
denominator: 625
FractionParts(π)
numerator: 2549491779
denominator: 811528438
ToFraction(ans)
2549491779/811528438 (=3.14159265359)