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
d2a9b20e
Kaydet (Commit)
d2a9b20e
authored
Ara 04, 2010
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #10596: Fix float.__mod__ to have the same behaviour as
float.__divmod__ with respect to signed zeros.
üst
7f4bc00d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
4 deletions
+38
-4
test_float.py
Lib/test/test_float.py
+20
-0
NEWS
Misc/NEWS
+4
-0
floatobject.c
Objects/floatobject.c
+14
-4
No files found.
Lib/test/test_float.py
Dosyayı görüntüle @
d2a9b20e
...
...
@@ -196,6 +196,26 @@ class GeneralFloatCases(unittest.TestCase):
# distingishes -0.0 and 0.0.
self
.
assertEqual
((
a
,
copysign
(
1.0
,
a
)),
(
b
,
copysign
(
1.0
,
b
)))
@requires_IEEE_754
def
test_float_mod
(
self
):
# Check behaviour of % operator for IEEE 754 special cases.
# In particular, check signs of zeros.
mod
=
operator
.
mod
self
.
assertEqualAndEqualSign
(
mod
(
-
1.0
,
1.0
),
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
-
1e-100
,
1.0
),
1.0
)
self
.
assertEqualAndEqualSign
(
mod
(
-
0.0
,
1.0
),
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
0.0
,
1.0
),
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
1e-100
,
1.0
),
1e-100
)
self
.
assertEqualAndEqualSign
(
mod
(
1.0
,
1.0
),
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
-
1.0
,
-
1.0
),
-
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
-
1e-100
,
-
1.0
),
-
1e-100
)
self
.
assertEqualAndEqualSign
(
mod
(
-
0.0
,
-
1.0
),
-
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
0.0
,
-
1.0
),
-
0.0
)
self
.
assertEqualAndEqualSign
(
mod
(
1e-100
,
-
1.0
),
-
1.0
)
self
.
assertEqualAndEqualSign
(
mod
(
1.0
,
-
1.0
),
-
0.0
)
@requires_IEEE_754
def
test_float_pow
(
self
):
# test builtin pow and ** operator for IEEE 754 special cases.
...
...
Misc/NEWS
Dosyayı görüntüle @
d2a9b20e
...
...
@@ -10,6 +10,10 @@ What's New in Python 3.2 Beta 1?
Core and Builtins
-----------------
- Issue #10596: Fix float.__mod__ to have the same behaviour as
float.__divmod__ with respect to signed zeros. -4.0 % 4.0 should be
0.0, not -0.0.
- Issue #1772833: Add the -q command-line option to suppress copyright
and version output in interactive mode.
...
...
Objects/floatobject.c
Dosyayı görüntüle @
d2a9b20e
...
...
@@ -600,10 +600,20 @@ float_rem(PyObject *v, PyObject *w)
}
PyFPE_START_PROTECT
(
"modulo"
,
return
0
)
mod
=
fmod
(
vx
,
wx
);
/* note: checking mod*wx < 0 is incorrect -- underflows to
0 if wx < sqrt(smallest nonzero double) */
if
(
mod
&&
((
wx
<
0
)
!=
(
mod
<
0
)))
{
mod
+=
wx
;
if
(
mod
)
{
/* ensure the remainder has the same sign as the denominator */
if
((
wx
<
0
)
!=
(
mod
<
0
))
{
mod
+=
wx
;
}
}
else
{
/* the remainder is zero, and in the presence of signed zeroes
fmod returns different results across platforms; ensure
it has the same sign as the denominator; we'd like to do
"mod = wx * 0.0", but that may get optimized away */
mod
*=
mod
;
/* hide "mod = +0" from optimizer */
if
(
wx
<
0
.
0
)
mod
=
-
mod
;
}
PyFPE_END_PROTECT
(
mod
)
return
PyFloat_FromDouble
(
mod
);
...
...
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