Raymond Hettinger wrote:

> I think this would harm more than it would help.  It more confusing to 
> have several rounding-thingies to choose from than it is have an 
> explicit two-step.

But is it more confusing enough to be worth forcing
everyone to pay two function calls instead of one
in the most common case?

If I'm right that rounding-to-int is much more
commonly needed than rounding-to-float, the least
confusing thing would be for the builtin round()
to return an int, and have something somewhere
else, such as math.fround(), for round-to-float.

> BTW,  I thought the traditional idiom (for positive numbers) was:  
> int(x+.5)

It's the "for positive numbers" that's the problem
there. Most of my uses for round() involve graphics
coordinates, which I can't be sure won't be negative.
It's not immediately obvious what this will do with
negative numbers. It's not even immediately obvious
that it's doing round-to-nearest-integer unless
you're familiar with the idiom. A single well-named
function would be much more explicit.

--
Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to