This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients belopolsky, mark.dickinson, mcherm, rhettinger, stutzbach, tim.peters, vstinner
Date 2010-05-31.19:42:04
SpamBayes Score 0.00034150042
Marked as misclassified No
Message-id <1275334928.25.0.932964742273.issue8860@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-05-31 19:42:08mark.dickinsonsetrecipients: + mark.dickinson, tim.peters, mcherm, rhettinger, belopolsky, vstinner, stutzbach
2010-05-31 19:42:08mark.dickinsonsetmessageid: <1275334928.25.0.932964742273.issue8860@psf.upfronthosting.co.za>
2010-05-31 19:42:06mark.dickinsonlinkissue8860 messages
2010-05-31 19:42:04mark.dickinsoncreate