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
2bebadfe
Kaydet (Commit)
2bebadfe
authored
Ock 21, 2008
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 1678380: fix a bug identifying -0.0 and 0.0
üst
78d50ccd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletion
+38
-1
test_float.py
Lib/test/test_float.py
+21
-0
NEWS
Misc/NEWS
+3
-0
compile.c
Python/compile.c
+14
-1
No files found.
Lib/test/test_float.py
Dosyayı görüntüle @
2bebadfe
...
...
@@ -99,6 +99,27 @@ class IEEEFormatTestCase(unittest.TestCase):
(
'<f'
,
LE_FLOAT_NAN
)]:
struct
.
unpack
(
fmt
,
data
)
if
float
.
__getformat__
(
"double"
)
.
startswith
(
"IEEE"
):
def
test_negative_zero
(
self
):
import
math
def
pos_pos
():
return
0.0
,
math
.
atan2
(
0.0
,
-
1
)
def
pos_neg
():
return
0.0
,
math
.
atan2
(
-
0.0
,
-
1
)
def
neg_pos
():
return
-
0.0
,
math
.
atan2
(
0.0
,
-
1
)
def
neg_neg
():
return
-
0.0
,
math
.
atan2
(
-
0.0
,
-
1
)
self
.
assertEquals
(
pos_pos
(),
neg_pos
())
self
.
assertEquals
(
pos_neg
(),
neg_neg
())
if
float
.
__getformat__
(
"double"
)
.
startswith
(
"IEEE"
):
def
test_underflow_sign
(
self
):
import
math
# check that -1e-1000 gives -0.0, not 0.0
self
.
assertEquals
(
math
.
atan2
(
-
1e-1000
,
-
1
),
math
.
atan2
(
-
0.0
,
-
1
))
self
.
assertEquals
(
math
.
atan2
(
float
(
'-1e-1000'
),
-
1
),
math
.
atan2
(
-
0.0
,
-
1
))
def
test_main
():
test_support
.
run_unittest
(
...
...
Misc/NEWS
Dosyayı görüntüle @
2bebadfe
...
...
@@ -12,6 +12,9 @@ What's New in Python 2.5.2c1?
Core and builtins
-----------------
- Issue #1678380: distinction between 0.0 and -0.0 was lost during constant
folding optimization. This was a regression from Python 2.4.
- Issue #1882: when compiling code from a string, encoding cookies in the
second line of code were not always recognized correctly.
...
...
Python/compile.c
Dosyayı görüntüle @
2bebadfe
...
...
@@ -1567,7 +1567,20 @@ compiler_add_o(struct compiler *c, PyObject *dict, PyObject *o)
Py_ssize_t
arg
;
/* necessary to make sure types aren't coerced (e.g., int and long) */
t
=
PyTuple_Pack
(
2
,
o
,
o
->
ob_type
);
/* _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms */
if
(
PyFloat_Check
(
o
))
{
double
d
=
PyFloat_AS_DOUBLE
(
o
);
unsigned
char
*
p
=
(
unsigned
char
*
)
&
d
;
/* all we need is to make the tuple different in either the 0.0
* or -0.0 case from all others, just to avoid the "coercion".
*/
if
(
*
p
==
0
&&
p
[
sizeof
(
double
)
-
1
]
==
0
)
t
=
PyTuple_Pack
(
3
,
o
,
o
->
ob_type
,
Py_None
);
else
t
=
PyTuple_Pack
(
2
,
o
,
o
->
ob_type
);
}
else
{
t
=
PyTuple_Pack
(
2
,
o
,
o
->
ob_type
);
}
if
(
t
==
NULL
)
return
-
1
;
...
...
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