Mark Dickinson <dicki...@gmail.com> added the comment: I agree it would be nice to fix this. We could either (1) alter delta_new so that the final round uses round-to-nearest; this would give the desired behaviour in most cases, but there would still be a small possibility of rounding going in the wrong direction as a result of accumulated errors in 'leftover_us'. Or (2) rewrite delta_new to do correct rounding in all cases, by using integer arithmetic where necessary.
(2) seems like overkill to me. For (1), it looks like it would be enough just to replace the round_to_long function with: static long round_to_long(double x) { return (long)round(x); } Actually, at this point, one might as well just inline round_to_long. Note that round_to_long is also called from datetime_from_timestamp. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue8860> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com