homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients Arfrever, alex, belopolsky, casevh, pitrou, rhettinger, skrah, tim.peters
Date 2014年09月22日.15:39:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1411400383.0.0.110517193167.issue22444@psf.upfronthosting.co.za>
In-reply-to
Content
[Raymond]
> The current behavior has been around for a long time and is implemented in several modules including decimal and fractions.
No, in the fractions module floor division returns an int:
>>> type(Fraction(2) // Fraction(1))
<class 'int'>
It is also implemented in the datetime module where
>>> type(timedelta(2) // timedelta(1))
<class 'int'>
[Raymond]
# Here is a simple example of a chain of calculations 
# where preserving the type matters
..
def f(x, y):
 return x // 3 * 5 / 7 + y
def g(x, y):
 return int(x // 3) * 5 / 7 + y
[/Raymond]
I am not sure what is the problem here. In Python 3:
>>> f(12.143, 0.667)
3.5241428571428575
>>> g(12.143, 0.667)
3.5241428571428575
History
Date User Action Args
2014年09月22日 15:39:43belopolskysetrecipients: + belopolsky, tim.peters, rhettinger, pitrou, casevh, Arfrever, alex, skrah
2014年09月22日 15:39:43belopolskysetmessageid: <1411400383.0.0.110517193167.issue22444@psf.upfronthosting.co.za>
2014年09月22日 15:39:42belopolskylinkissue22444 messages
2014年09月22日 15:39:42belopolskycreate

AltStyle によって変換されたページ (->オリジナル) /