for / while else doesn't make sense

Ian Kelly ian.g.kelly at gmail.com
Mon May 23 10:49:12 EDT 2016


On Mon, May 23, 2016 at 8:29 AM, Ben Bacarisse <ben.usenet at bsb.me.uk> wrote:
> Ian Kelly <ian.g.kelly at gmail.com> writes:
>
>> On Mon, May 23, 2016 at 2:09 AM, Steven D'Aprano
>> <steve+comp.lang.python at pearwood.info> wrote:
>>> Are you saying that the Egyptians, Babylonians and Greeks didn't know how to
>>> work with fractions?
>>>
>>> http://mathworld.wolfram.com/EgyptianFraction.html
>>>
>>> http://nrich.maths.org/2515
>>>
>>> Okay, it's not quite 4000 years ago. Sometimes my historical sense of the
>>> distant past is a tad inaccurate. Shall we say 2000 years instead?
>>
>> Those links give dates of 1650 BC and 1800 BC respectively, so I'd say
>> your initial guess was closer.
>
> Right, but this is to miss the point.  Let's say that 4000 years have
> defined 1/3 to be one third, but Python 3 (as do many programming
> languages) defines 1/3 to be something very very very very close to one
> third, and *that* idea is very very very very new!  It's unfortunate
> that the example in this thread does not illustrate the main problem of
> shifting to binary floating point, because 1/2 happens to be exactly
> representable.

I'm not going to dig back through the thread, but my recollection is
that's exactly why that example was chosen. Since 1/2 can be
represented exactly as a float, it *should* be represented as a float.
Picking another value (0) that isn't even close to the exact value of
1/2 isn't helping anybody.



More information about the Python-list mailing list