On Mon, May 23, 2016 at 1:19 AM, Steven D'Aprano <st...@pearwood.info> wrote: > Okay, now I'm confused. How is 1/2 returning 0.5 the language not doing what > you've told it to do?
That isn't the problem. With binary floats, 1/2 can be perfectly represented, so you have no trouble anywhere. The problem comes when you then try 1/5. What do you get? 3602879701896397/18014398509481984. Python shows that as 0.2. Then you do some more arithmetic, and the veil is pierced, and you discover that 1/5 doesn't actually return 0.2, but just something really really close to it - which it tells you is 0.2. I'm not saying that having 1/5 return 0 is better, but I'd like a broad acceptance that 0.2 is imperfect - that, in fact, *every* option is imperfect. ChrisA -- https://mail.python.org/mailman/listinfo/python-list