Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9296023

Browse files
committed
Improve examples for working with the context API.
1 parent ef66deb commit 9296023

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/lib/libdecimal.tex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ \subsection{Quick-start Tutorial \label{decimal-tutorial}}
179179
'1.34'
180180
>>> float(a)
181181
1.3400000000000001
182-
>>> round(a, 1)
182+
>>> round(a, 1) # round() first converts to binary floating point
183183
1.3
184184
>>> int(a)
185185
1
@@ -217,9 +217,6 @@ \subsection{Quick-start Tutorial \label{decimal-tutorial}}
217217

218218
\begin{verbatim}
219219
>>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN)
220-
>>> myothercontext
221-
Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999,
222-
capitals=1, flags=[], traps=[])
223220
>>> setcontext(myothercontext)
224221
>>> Decimal(1) / Decimal(7)
225222
Decimal("0.142857142857142857142857142857142857142857142857142857142857")
@@ -855,10 +852,13 @@ \subsection{Working with threads \label{decimal-threads}}
855852

856853
\begin{verbatim}
857854
# Set applicationwide defaults for all threads about to be launched
858-
DefaultContext = Context(prec=12, rounding=ROUND_DOWN, traps=[InvalidOperation])
855+
DefaultContext.prec = 12
856+
DefaultContext.rounding = ROUND_DOWN
857+
DefaultContext.traps = ExtendedContext.traps.copy()
858+
DefaultContext.traps[InvalidOperation] = 1
859859
setcontext(DefaultContext)
860860
861-
# Afterward, the threads can be started
861+
# Afterwards, the threads can be started
862862
t1.start()
863863
t2.start()
864864
t3.start()

0 commit comments

Comments
 (0)