Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
bd7f76dd
Kaydet (Commit)
bd7f76dd
authored
Tem 08, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Tim gets his default traps.
üst
4e0e1b6a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
decimal.py
Lib/decimal.py
+10
-8
No files found.
Lib/decimal.py
Dosyayı görüntüle @
bd7f76dd
...
@@ -31,7 +31,7 @@ of the expected Decimal("0.00") returned by decimal floating point).
...
@@ -31,7 +31,7 @@ of the expected Decimal("0.00") returned by decimal floating point).
Here are some examples of using the decimal module:
Here are some examples of using the decimal module:
>>> from decimal import *
>>> from decimal import *
>>>
getcontext().prec=9
>>>
setcontext(ExtendedContext)
>>> Decimal(0)
>>> Decimal(0)
Decimal("0")
Decimal("0")
>>> Decimal("1")
>>> Decimal("1")
...
@@ -405,8 +405,8 @@ if hasattr(threading.currentThread(), '__decimal_context__'):
...
@@ -405,8 +405,8 @@ if hasattr(threading.currentThread(), '__decimal_context__'):
def
setcontext
(
context
):
def
setcontext
(
context
):
"""Set this thread's context to context."""
"""Set this thread's context to context."""
if
context
==
DefaultContext
:
if
context
in
(
DefaultContext
,
BasicContext
,
ExtendedContext
)
:
context
=
Context
()
context
=
context
.
copy
()
threading
.
currentThread
()
.
__decimal_context__
=
context
threading
.
currentThread
()
.
__decimal_context__
=
context
def
getcontext
():
def
getcontext
():
...
@@ -2960,28 +2960,30 @@ def _isnan(num):
...
@@ -2960,28 +2960,30 @@ def _isnan(num):
##### Setup Specific Contexts ################################
##### Setup Specific Contexts ################################
_basic_traps
=
dict
.
fromkeys
(
Signals
,
1
)
_basic_traps
.
update
({
Inexact
:
0
,
Rounded
:
0
,
Subnormal
:
0
})
# The default context prototype used by Context()
# The default context prototype used by Context()
# Is mutable, so than new contexts can have different default values
# Is mutable, so than new contexts can have different default values
_default_traps
=
dict
.
fromkeys
(
Signals
,
0
)
_default_traps
.
update
({
DivisionByZero
:
1
,
Overflow
:
1
,
InvalidOperation
:
1
})
DefaultContext
=
Context
(
DefaultContext
=
Context
(
prec
=
28
,
rounding
=
ROUND_HALF_EVEN
,
prec
=
28
,
rounding
=
ROUND_HALF_EVEN
,
trap_enablers
=
dict
.
fromkeys
(
Signals
,
0
)
,
trap_enablers
=
_default_traps
,
flags
=
None
,
flags
=
None
,
_rounding_decision
=
ALWAYS_ROUND
,
_rounding_decision
=
ALWAYS_ROUND
,
Emax
=
DEFAULT_MAX_EXPONENT
,
Emax
=
DEFAULT_MAX_EXPONENT
,
Emin
=
DEFAULT_MIN_EXPONENT
,
Emin
=
DEFAULT_MIN_EXPONENT
,
capitals
=
1
capitals
=
1
)
)
DefaultContext
.
trap_enablers
.
update
({
ConversionSyntax
:
1
})
# Pre-made alternate contexts offered by the specification
# Pre-made alternate contexts offered by the specification
# Don't change these; the user should be able to select these
# Don't change these; the user should be able to select these
# contexts and be able to reproduce results from other implementations
# contexts and be able to reproduce results from other implementations
# of the spec.
# of the spec.
_basic_traps
=
dict
.
fromkeys
(
Signals
,
1
)
_basic_traps
.
update
({
Inexact
:
0
,
Rounded
:
0
,
Subnormal
:
0
})
BasicContext
=
Context
(
BasicContext
=
Context
(
prec
=
9
,
rounding
=
ROUND_HALF_UP
,
prec
=
9
,
rounding
=
ROUND_HALF_UP
,
trap_enablers
=
_basic_traps
,
trap_enablers
=
_basic_traps
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment