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
2c8c62e6
Kaydet (Commit)
2c8c62e6
authored
Mar 12, 2011
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 11131: Fix sign of zero result on plus and minus operations in ROUND_FLOOR rounding mode.
üst
d4f016fb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
8 deletions
+84
-8
decimal.py
Lib/decimal.py
+11
-8
extra.decTest
Lib/test/decimaltestdata/extra.decTest
+70
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/decimal.py
Dosyayı görüntüle @
2c8c62e6
...
...
@@ -1068,14 +1068,16 @@ class Decimal(object):
if
ans
:
return
ans
if
not
self
:
# -Decimal('0') is Decimal('0'), not Decimal('-0')
if
context
is
None
:
context
=
getcontext
()
if
not
self
and
context
.
rounding
!=
ROUND_FLOOR
:
# -Decimal('0') is Decimal('0'), not Decimal('-0'), except
# in ROUND_FLOOR rounding mode.
ans
=
self
.
copy_abs
()
else
:
ans
=
self
.
copy_negate
()
if
context
is
None
:
context
=
getcontext
()
return
ans
.
_fix
(
context
)
def
__pos__
(
self
,
context
=
None
):
...
...
@@ -1088,14 +1090,15 @@ class Decimal(object):
if
ans
:
return
ans
if
not
self
:
# + (-0) = 0
if
context
is
None
:
context
=
getcontext
()
if
not
self
and
context
.
rounding
!=
ROUND_FLOOR
:
# + (-0) = 0, except in ROUND_FLOOR rounding mode.
ans
=
self
.
copy_abs
()
else
:
ans
=
Decimal
(
self
)
if
context
is
None
:
context
=
getcontext
()
return
ans
.
_fix
(
context
)
def
__abs__
(
self
,
round
=
True
,
context
=
None
):
...
...
Lib/test/decimaltestdata/extra.decTest
Dosyayı görüntüle @
2c8c62e6
...
...
@@ -2745,3 +2745,73 @@ pwmx437 power 17 1728 1729 -> 1
pwmx438 power 18 1728 1729 -> 1
pwmx439 power 19 1728 1729 -> 456
pwmx440 power 20 1728 1729 -> 1
-- plus and minus zero in various rounding modes (see issue 11131)
extended: 1
precision: 9
maxexponent: 384
minexponent: -383
rounding: half_even
plux1000 plus 0.0 -> 0.0
plux1001 plus -0.0 -> 0.0
minx1000 minus 0.0 -> 0.0
minx1001 minus -0.0 -> 0.0
absx1000 abs 0.0 -> 0.0
absx1001 abs -0.0 -> 0.0
rounding: half_up
plux1010 plus 0.0 -> 0.0
minx1010 minus 0.0 -> 0.0
plux1011 plus -0.0 -> 0.0
minx1011 minus -0.0 -> 0.0
absx1010 abs 0.0 -> 0.0
absx1011 abs -0.0 -> 0.0
rounding: ceiling
plux1020 plus 0.0 -> 0.0
minx1020 minus 0.0 -> 0.0
plux1021 plus -0.0 -> 0.0
minx1021 minus -0.0 -> 0.0
absx1020 abs 0.0 -> 0.0
absx1021 abs -0.0 -> 0.0
rounding: floor
plux1030 plus 0.0 -> 0.0
minx1030 minus 0.0 -> -0.0
plux1031 plus -0.0 -> -0.0
minx1031 minus -0.0 -> 0.0
absx1030 abs 0.0 -> 0.0
absx1031 abs -0.0 -> 0.0
rounding: down
plux1040 plus 0.0 -> 0.0
minx1040 minus 0.0 -> 0.0
plux1041 plus -0.0 -> 0.0
minx1041 minus -0.0 -> 0.0
absx1040 abs 0.0 -> 0.0
absx1041 abs -0.0 -> 0.0
rounding: up
plux1050 plus 0.0 -> 0.0
minx1050 minus 0.0 -> 0.0
plux1051 plus -0.0 -> 0.0
minx1051 minus -0.0 -> 0.0
absx1050 abs 0.0 -> 0.0
absx1051 abs -0.0 -> 0.0
rounding: half_down
plux1060 plus 0.0 -> 0.0
minx1060 minus 0.0 -> 0.0
plux1061 plus -0.0 -> 0.0
minx1061 minus -0.0 -> 0.0
absx1060 abs 0.0 -> 0.0
absx1061 abs -0.0 -> 0.0
rounding: 05up
plux1070 plus 0.0 -> 0.0
minx1070 minus 0.0 -> 0.0
plux1071 plus -0.0 -> 0.0
minx1071 minus -0.0 -> 0.0
absx1070 abs 0.0 -> 0.0
absx1071 abs -0.0 -> 0.0
Misc/NEWS
Dosyayı görüntüle @
2c8c62e6
...
...
@@ -43,6 +43,9 @@ Core and Builtins
Library
-------
- Issue #11131: Fix sign of zero in plus and minus operations when
the context rounding mode is ROUND_FLOOR.
- Issue #5622: Fix curses.wrapper to raise correct exception if curses
initialization fails.
...
...
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