Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Changing the title from referring to "decimal" to "float", since this has nothing to do with the decimal module or Decimal type. Like Raymond and Tim, I too cannot reproduce the claimed difference in behaviour between Python 2.7 and 3.x. Au Vo, there are many resources on the web explaining why floats such as 0.4 do not equal exactly four tenths. One of the best (but not the easiest to understand) is What Every Computer Scientist Should Know About Floating-Point Arithmetic https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html A more accessible (to me at least) resource is Bruce Dawson's blog: https://randomascii.wordpress.com/category/floating-point/page/1/ although it is written from the perspective of a C programmer. There's also a Python FAQ about it: https://docs.python.org/3/faq/design.html#why-are-floating-point-calculations-so-inaccurate ---------- nosy: +steven.daprano title: Integer Division discrepancy with decimal -> Integer Division discrepancy with float _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36028> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com