Skip to content

Commit 28b661c

Browse files
committed
round if it has decimal points
1 parent 10b28c1 commit 28b661c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Modules/_datetimemodule.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,8 +3357,11 @@ delta_total_seconds(PyObject *op, PyObject *Py_UNUSED(dummy))
33573357
+ (double)seconds
33583358
+ (double)microseconds * 1e-6
33593359
+ (double)nanoseconds * 1e-9;
3360-
// round to 9 decimal places
3361-
total = roundl(total * 1e9) / 1e9;
3360+
// check for decimal parts
3361+
if ((long)total != total){
3362+
// round to 9 decimal places
3363+
total = roundl(total * 1e9) / 1e9;
3364+
}
33623365
return PyFloat_FromDouble(total);
33633366
}
33643367

0 commit comments

Comments
 (0)