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
ccadf84a
Kaydet (Commit)
ccadf84a
authored
Mar 31, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Patch #1460496: round() now accepts keyword arguments.
üst
338ef7d2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
12 deletions
+19
-12
test_builtin.py
Lib/test/test_builtin.py
+3
-0
NEWS
Misc/NEWS
+2
-0
bltinmodule.c
Python/bltinmodule.c
+14
-12
No files found.
Lib/test/test_builtin.py
Dosyayı görüntüle @
ccadf84a
...
...
@@ -1395,6 +1395,9 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
round
(
-
8.0
,
-
1
),
-
10.0
)
# test new kwargs
self
.
assertEqual
(
round
(
number
=-
8.0
,
ndigits
=-
1
),
-
10.0
)
self
.
assertRaises
(
TypeError
,
round
)
def
test_setattr
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
ccadf84a
...
...
@@ -12,6 +12,8 @@ What's New in Python 2.5 alpha 1?
Core and builtins
-----------------
- Patch #1460496: round() now accepts keyword arguments.
- Fixed bug #1459029 - unicode reprs were double-escaped.
- Patch #1396919: The system scope threads are reenabled on FreeBSD
...
...
Python/bltinmodule.c
Dosyayı görüntüle @
ccadf84a
...
...
@@ -1870,32 +1870,34 @@ For most object types, eval(repr(object)) == object.");
static
PyObject
*
builtin_round
(
PyObject
*
self
,
PyObject
*
args
)
builtin_round
(
PyObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
{
double
x
;
double
number
;
double
f
;
int
ndigits
=
0
;
int
i
;
static
char
*
kwlist
[]
=
{
"number"
,
"ndigits"
,
0
};
if
(
!
PyArg_ParseTuple
(
args
,
"d|i:round"
,
&
x
,
&
ndigits
))
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwds
,
"d|i:round"
,
kwlist
,
&
number
,
&
ndigits
))
return
NULL
;
f
=
1
.
0
;
i
=
abs
(
ndigits
);
while
(
--
i
>=
0
)
f
=
f
*
10
.
0
;
if
(
ndigits
<
0
)
x
/=
f
;
number
/=
f
;
else
x
*=
f
;
if
(
x
>=
0
.
0
)
x
=
floor
(
x
+
0
.
5
);
number
*=
f
;
if
(
number
>=
0
.
0
)
number
=
floor
(
number
+
0
.
5
);
else
x
=
ceil
(
x
-
0
.
5
);
number
=
ceil
(
number
-
0
.
5
);
if
(
ndigits
<
0
)
x
*=
f
;
number
*=
f
;
else
x
/=
f
;
return
PyFloat_FromDouble
(
x
);
number
/=
f
;
return
PyFloat_FromDouble
(
number
);
}
PyDoc_STRVAR
(
round_doc
,
...
...
@@ -2248,7 +2250,7 @@ static PyMethodDef builtin_methods[] = {
{
"reduce"
,
builtin_reduce
,
METH_VARARGS
,
reduce_doc
},
{
"reload"
,
builtin_reload
,
METH_O
,
reload_doc
},
{
"repr"
,
builtin_repr
,
METH_O
,
repr_doc
},
{
"round"
,
builtin_round
,
METH_VARARG
S
,
round_doc
},
{
"round"
,
(
PyCFunction
)
builtin_round
,
METH_VARARGS
|
METH_KEYWORD
S
,
round_doc
},
{
"setattr"
,
builtin_setattr
,
METH_VARARGS
,
setattr_doc
},
{
"sorted"
,
(
PyCFunction
)
builtin_sorted
,
METH_VARARGS
|
METH_KEYWORDS
,
sorted_doc
},
{
"sum"
,
builtin_sum
,
METH_VARARGS
,
sum_doc
},
...
...
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