[New-bugs-announce] [issue39703] Floor division operator and floats

Kostis Gourgoulias report at bugs.python.org
Thu Feb 20 11:25:56 EST 2020


New submission from Kostis Gourgoulias <kgourgoulias at gmail.com>:

This was brought to my attention by a colleague, Albert B.

When considering the floor division // operator, 1//0.01 should return 100.0, but instead returns 99.0. My understanding is that this is because 0.01 is represented by 

Decimal('0.01000000000000000020816681711721685132943093776702880859375')

which is greater than 0.01.

math.floor(1/0.01) correctly outputs 100. Shouldn't the two approaches provide the same answer?

----------
components: macOS
messages: 362330
nosy: Kostis Gourgoulias, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: Floor division operator and floats
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39703>
_______________________________________


More information about the New-bugs-announce mailing list