[Python-checkins] python/dist/src/Doc/lib libdecimal.tex,1.6,1.7
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Tue Jul 6 03:55:17 CEST 2004
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22699
Modified Files:
libdecimal.tex
Log Message:
Demonstrate how to round final result.
Index: libdecimal.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdecimal.tex,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** libdecimal.tex 5 Jul 2004 21:13:28 -0000 1.6
--- libdecimal.tex 6 Jul 2004 01:55:14 -0000 1.7
***************
*** 933,939 ****
>>> print pi()
! 3.141592653589793238462643383279502887
"""
! getcontext().prec += 9 # extra digits for intermediate steps
three = Decimal(3) # substitute "three=3.0" for regular floats
lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24
--- 933,939 ----
>>> print pi()
! 3.141592653589793238462643383
"""
! getcontext().prec += 2 # extra digits for intermediate steps
three = Decimal(3) # substitute "three=3.0" for regular floats
lastc, t, c, n, na, d, da = 0, three, 3, 1, 0, 0, 24
***************
*** 944,949 ****
t = (t * n) / d
c += t
! getcontext().prec -= 9
! return c
def exp(x):
--- 944,949 ----
t = (t * n) / d
c += t
! getcontext().prec -= 2
! return c + 0
def exp(x):
***************
*** 951,957 ****
>>> print exp(Decimal(1))
! 2.718281828459045235360287471352662498
>>> print exp(Decimal(2))
! 7.389056098930650227230427460575007813
>>> print exp(2.0)
7.38905609893
--- 951,957 ----
>>> print exp(Decimal(1))
! 2.718281828459045235360287471
>>> print exp(Decimal(2))
! 7.389056098930650227230427461
>>> print exp(2.0)
7.38905609893
***************
*** 959,963 ****
(7.38905609893+0j)
"""
! getcontext().prec += 9 # extra digits for intermediate steps
i, laste, e, fact, num = 0, 0, 1, 1, 1
while e != laste:
--- 959,963 ----
(7.38905609893+0j)
"""
! getcontext().prec += 2 # extra digits for intermediate steps
i, laste, e, fact, num = 0, 0, 1, 1, 1
while e != laste:
***************
*** 967,972 ****
num *= x
e += num / fact
! getcontext().prec -= 9
! return e
def cos(x):
--- 967,972 ----
num *= x
e += num / fact
! getcontext().prec -= 2
! return e + 0
def cos(x):
***************
*** 974,978 ****
>>> print cos(Decimal('0.5'))
! 0.8775825618903727161162815826038296521
>>> print cos(0.5)
0.87758256189
--- 974,978 ----
>>> print cos(Decimal('0.5'))
! 0.8775825618903727161162815826
>>> print cos(0.5)
0.87758256189
***************
*** 980,984 ****
(0.87758256189+0j)
"""
! getcontext().prec += 9 # extra digits for intermediate steps
i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1
while e != laste:
--- 980,984 ----
(0.87758256189+0j)
"""
! getcontext().prec += 2 # extra digits for intermediate steps
i, laste, e, fact, num, sign = 0, 0, 1, 1, 1, 1
while e != laste:
***************
*** 989,994 ****
sign *= -1
e += num / fact * sign
! getcontext().prec -= 9
! return e
def sin(x):
--- 989,994 ----
sign *= -1
e += num / fact * sign
! getcontext().prec -= 2
! return e + 0
def sin(x):
***************
*** 996,1000 ****
>>> print sin(Decimal('0.5'))
! 0.4794255386042030002732879352155713880
>>> print sin(0.5)
0.479425538604
--- 996,1000 ----
>>> print sin(Decimal('0.5'))
! 0.4794255386042030002732879352
>>> print sin(0.5)
0.479425538604
***************
*** 1002,1006 ****
(0.479425538604+0j)
"""
! getcontext().prec += 9 # extra digits for intermediate steps
i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1
while e != laste:
--- 1002,1006 ----
(0.479425538604+0j)
"""
! getcontext().prec += 2 # extra digits for intermediate steps
i, laste, e, fact, num, sign = 1, 0, x, 1, x, 1
while e != laste:
***************
*** 1011,1016 ****
sign *= -1
e += num / fact * sign
! getcontext().prec -= 9
! return e
\end{verbatim}
--- 1011,1016 ----
sign *= -1
e += num / fact * sign
! getcontext().prec -= 2
! return e + 0
\end{verbatim}
More information about the Python-checkins
mailing list