How is Python's ROUND_HALF_EVEN supposed to handle decimals smaller than 1? -
it appears in every definition can find of round half even
includes nearest integer
(e.g., python's decimal documentation), if integers rounded to. however, if round decimals smaller 1, appears follow same principal, assigning role of integer
decimal place rounding to. example:
>>> three_places = decimal.decimal('0.000') >>> >>> decimal.decimal('.0005').quantize(three_places) >>> decimal('0.000') >>> >>> decimal.decimal('.0015').quantize(three_places) >>> decimal('0.002')
in example, value of third decimal place seems play role of integer (rounding down 0
, 2
). the specified way of handling numbers less 0 (and how python's round_half_even
supposed function), , if so, misunderstanding meaning of "integer" in context? or, there more story, , perhaps merely coincidence?
your interpretation correct. documentation isn't clear , should use word digit
instead of integer
. round_half_even implies last digit of result (when rounding away ....5000).
Comments
Post a Comment