add an example after all
This commit is contained in:
parent
9256ca5df7
commit
c5a5043cf7
1 changed files with 22 additions and 0 deletions
22
examples/udecimal_simpletest.py
Normal file
22
examples/udecimal_simpletest.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# SPDX-FileCopyrightText: 2020 Jeff Epler <https://unpythonic.net>
|
||||
#
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
# pylint: disable=wrong-import-position,unused-import
|
||||
|
||||
from jepler_udecimal import Decimal as D
|
||||
from jepler_udecimal import localcontext
|
||||
|
||||
d = D(".1")
|
||||
e = D(".2")
|
||||
f = D(".3")
|
||||
g = D(".4")
|
||||
# Prints 0 because all values involved are exact decimals
|
||||
print(d + e + f + g - 1)
|
||||
|
||||
import jepler_udecimal.utrig
|
||||
|
||||
# Approximates pi to 78 decimal places
|
||||
with localcontext() as ctx:
|
||||
ctx.prec = 78
|
||||
print(D("1").atan() * 4)
|
||||
Loading…
Reference in a new issue