Skip to content

Commit c5a5043

Browse files
committed
add an example after all
1 parent 9256ca5 commit c5a5043

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/udecimal_simpletest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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)

0 commit comments

Comments
 (0)