[Tutor] floating point rounding inconsistency

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Sep 29 03:29:27 CEST 2012


On 28/09/2012 22:07, eryksun wrote:
> On Fri, Sep 28, 2012 at 9:17 AM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
>> On 28/09/2012 13:37, Steven D'Aprano wrote:
>>
>>> Deprecating and dropping features causes pain to developers who are
>>> already using them correctly. There is strong opposition on deprecating
>>> round.
>>
>> And there is strong support for deprecating round.  Personally I'm staying
>> out of the blood bath as I've never used it :)
>
> That would be an odd back-step since Python 3 generalized the built-in:
>
>      >>> class Test:
>      ...     def __round__(self, ndigits=None):
>      ...         return 1
>      ...
>      >>> round(Test())
>      1
>
> Also, float, Decimal, and Fraction in Python 3 return an int when the
> ndigits argument is omitted. For example, float rounds using the math
> lib's round function, then rounds that to even, and returns
> PyLong_FromDouble. Is the discussion just about removing the ndigits
> aspect but keeping the round-to-int aspect?

I don't have figures (ouch :) but some people appear to support complete 
deprecation, some leaving the status quo and some removing the ndigits 
aspect as you have asked.  Also remember that the idea is only being 
floated (double ouch:) on Python ideas so anything could happen.  Don't 
watch this space!!!

> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


-- 
Cheers.

Mark Lawrence.



More information about the Tutor mailing list