[Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.13,1.14

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Wed Jul 14 23:06:58 CEST 2004


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6506
Modified Files:
	libdecimal.tex 
Log Message:
Improve examples for working with the context API.
Index: libdecimal.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** libdecimal.tex	12 Jul 2004 13:22:14 -0000	1.13
--- libdecimal.tex	14 Jul 2004 21:06:55 -0000	1.14
***************
*** 180,184 ****
 >>> float(a)
 1.3400000000000001
! >>> round(a, 1)
 1.3
 >>> int(a)
--- 180,184 ----
 >>> float(a)
 1.3400000000000001
! >>> round(a, 1) # round() first converts to binary floating point
 1.3
 >>> int(a)
***************
*** 218,224 ****
 \begin{verbatim}
 >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN)
- >>> myothercontext
- Context(prec=60, rounding=ROUND_HALF_DOWN, Emin=-999999999, Emax=999999999,
- capitals=1, flags=[], traps=[])
 >>> setcontext(myothercontext)
 >>> Decimal(1) / Decimal(7)
--- 218,221 ----
***************
*** 856,863 ****
 \begin{verbatim}
 # Set applicationwide defaults for all threads about to be launched
! DefaultContext = Context(prec=12, rounding=ROUND_DOWN, traps=[InvalidOperation])
 setcontext(DefaultContext)
 
! # Afterward, the threads can be started
 t1.start()
 t2.start()
--- 853,863 ----
 \begin{verbatim}
 # Set applicationwide defaults for all threads about to be launched
! DefaultContext.prec = 12
! DefaultContext.rounding = ROUND_DOWN
! DefaultContext.traps = ExtendedContext.traps.copy()
! DefaultContext.traps[InvalidOperation] = 1
 setcontext(DefaultContext)
 
! # Afterwards, the threads can be started
 t1.start()
 t2.start()


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /