udecimal_simpletest.py
1 # SPDX-FileCopyrightText: 2020 Jeff Epler <https://unpythonic.net> 2 # 3 # SPDX-License-Identifier: Unlicense 4 5 # pylint: disable=wrong-import-position,unused-import 6 7 from jepler_udecimal import Decimal as D 8 from jepler_udecimal import localcontext 9 10 d = D(".1") 11 e = D(".2") 12 f = D(".3") 13 g = D(".4") 14 # Prints 0 because all values involved are exact decimals 15 print(d + e + f + g - 1) 16 17 import jepler_udecimal.utrig 18 19 # Approximates pi to 78 decimal places 20 with localcontext() as ctx: 21 ctx.prec = 78 22 print(D("1").atan() * 4)