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
f263724e
Kaydet (Commit)
f263724e
authored
Kas 09, 2009
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #7070: Fix problem with builtin round function for large odd
integer arguments. Also fixes the sign of round(-0.0).
üst
c747d3a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
test_builtin.py
Lib/test/test_builtin.py
+9
-0
NEWS
Misc/NEWS
+2
-0
bltinmodule.c
Python/bltinmodule.c
+9
-5
No files found.
Lib/test/test_builtin.py
Dosyayı görüntüle @
f263724e
# Python test set -- built-in functions
# Python test set -- built-in functions
import
platform
import
test.test_support
,
unittest
import
test.test_support
,
unittest
from
test.test_support
import
fcmp
,
have_unicode
,
TESTFN
,
unlink
,
\
from
test.test_support
import
fcmp
,
have_unicode
,
TESTFN
,
unlink
,
\
run_unittest
,
run_with_locale
run_unittest
,
run_with_locale
...
@@ -1259,6 +1260,14 @@ class BuiltinTest(unittest.TestCase):
...
@@ -1259,6 +1260,14 @@ class BuiltinTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
round
,
t
)
self
.
assertRaises
(
TypeError
,
round
,
t
)
self
.
assertRaises
(
TypeError
,
round
,
t
,
0
)
self
.
assertRaises
(
TypeError
,
round
,
t
,
0
)
def
test_round_large
(
self
):
# Issue #1869: integral floats should remain unchanged
self
.
assertEqual
(
round
(
5e15
-
1
),
5e15
-
1
)
self
.
assertEqual
(
round
(
5e15
),
5e15
)
self
.
assertEqual
(
round
(
5e15
+
1
),
5e15
+
1
)
self
.
assertEqual
(
round
(
5e15
+
2
),
5e15
+
2
)
self
.
assertEqual
(
round
(
5e15
+
3
),
5e15
+
3
)
def
test_setattr
(
self
):
def
test_setattr
(
self
):
setattr
(
sys
,
'spam'
,
1
)
setattr
(
sys
,
'spam'
,
1
)
self
.
assertEqual
(
sys
.
spam
,
1
)
self
.
assertEqual
(
sys
.
spam
,
1
)
...
...
Misc/NEWS
Dosyayı görüntüle @
f263724e
...
@@ -12,6 +12,8 @@ What's New in Python 2.6.5
...
@@ -12,6 +12,8 @@ What's New in Python 2.6.5
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #7070: Fix round bug for large odd integer arguments.
- Issue #7078: Set struct.__doc__ from _struct.__doc__.
- Issue #7078: Set struct.__doc__ from _struct.__doc__.
- Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which
- Issue #1722344: threading._shutdown() is now called in Py_Finalize(), which
...
...
Python/bltinmodule.c
Dosyayı görüntüle @
f263724e
...
@@ -2120,7 +2120,7 @@ For most object types, eval(repr(object)) == object.");
...
@@ -2120,7 +2120,7 @@ For most object types, eval(repr(object)) == object.");
static
PyObject
*
static
PyObject
*
builtin_round
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
builtin_round
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
{
double
number
;
double
number
,
abs_number
,
abs_result
;
double
f
;
double
f
;
int
ndigits
=
0
;
int
ndigits
=
0
;
int
i
;
int
i
;
...
@@ -2137,10 +2137,14 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
...
@@ -2137,10 +2137,14 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
number
/=
f
;
number
/=
f
;
else
else
number
*=
f
;
number
*=
f
;
if
(
number
>=
0
.
0
)
number
=
floor
(
number
+
0
.
5
);
/* round `number` to nearest integer, rounding halves away from zero */
else
abs_number
=
fabs
(
number
);
number
=
ceil
(
number
-
0
.
5
);
abs_result
=
floor
(
abs_number
);
if
(
abs_number
-
abs_result
>=
0
.
5
)
abs_result
+=
1
.
0
;
number
=
copysign
(
abs_result
,
number
);
if
(
ndigits
<
0
)
if
(
ndigits
<
0
)
number
*=
f
;
number
*=
f
;
else
else
...
...
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