Conversions (Rational)
Examples on this page assume from decimo.prelude import * and run inside def main() raises:.
print(Rational(1, 3).to_float()) # 0.3333333333333333
print(Rational(1, 3).to_bigdecimal(20)) # 0.33333333333333333333
print(Rational(-7, 2).to_integer()) # -3, truncated toward zero
print(Rational(-7, 2).reciprocal()) # -2/7
to_bigdecimal takes the digits to keep, because a third has no decimal
expansion that ends. Everything else here is exact.
Built from decimo main. This page in the manual.