diff options
author | Steve Dower <steve.dower@microsoft.com> | 2015-04-15 16:10:59 -0400 |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2015-04-15 16:10:59 -0400 |
commit | 393adbb245df09fe1dc8041ad2870d847595d73c (patch) | |
tree | 984b48d6f9d4bef19f64bd3df0f4c26cab7340e1 /Objects/floatobject.c | |
parent | 21e62c001a9553304202929717a1e3a4fe5e902d (diff) | |
download | cpython-393adbb245df09fe1dc8041ad2870d847595d73c.tar.gz |
Issue 19933: Provide default argument for ndigits in round. Patch by Vajrasky Kok.
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r-- | Objects/floatobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 1d369f98be..d6819814ef 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -986,8 +986,9 @@ float_round(PyObject *v, PyObject *args) x = PyFloat_AsDouble(v); if (!PyArg_ParseTuple(args, "|O", &o_ndigits)) return NULL; - if (o_ndigits == NULL) { - /* single-argument round: round to nearest integer */ + if (o_ndigits == NULL || o_ndigits == Py_None) { + /* single-argument round or with None ndigits: + * round to nearest integer */ rounded = round(x); if (fabs(x-rounded) == 0.5) /* halfway case: round to even */ |