[Python-ideas] Round division

Emile van Sebille emile at fenx.com
Fri Sep 11 18:18:52 CEST 2015


On 9/10/2015 11:27 PM, Serhiy Storchaka wrote:
> On 11.09.15 06:13, Steven D'Aprano wrote:
>> How does this differ from round(a/b)? round() also rounds to even.
>
>  >>> round(5000000000000000/9999999999999999)
> 0
>  >>> round(14999999999999999/10000000000000000)
> 2
>
> But fractions 5000000000000000/9999999999999999 > 1/2 and
> 14999999999999999/10000000000000000 < 3/2.
>

Wow -- I'm glad I work predominately in business environments and keep 
amounts in pennies.  The only time I need to round anything is to the 
nearest cent.

Emile




More information about the Python-ideas mailing list