Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread Antoine Pitrou
Le 22/09/2017 à 19:15, Tim Peters a écrit : > I've seen plenty of people on StackOverflow who (a) don't understand > hex notation for integers; and/or (b) don't understand scientific > notation for floats. Nothing is self-evident about either; they both > have to be learned at first. Sure. But,

Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread Tim Peters
[Antoine Pitrou ] > ... > The main difference is familiarity. "scientific" notation should be > well-known and understood even by high school kids. Who knows about > hexadecimal notation for floats, apart from floating-point experts? Here's an example: you <0x0.2p0 wink>. For people who unders

Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread Chris Barker
On Fri, Sep 22, 2017 at 8:37 AM, Guido van Rossum wrote: > On Thu, Sep 21, 2017 at 9:20 PM, Nick Coghlan wrote: > >> >>> one_tenth = 0x1.0 / 0xA.0 >> >>> two_tenths = 0x2.0 / 0xA.0 >> >>> three_tenths = 0x3.0 / 0xA.0 >> >>> three_tenths == one_tenth + two_tenths >> False >> >

Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread Guido van Rossum
On Thu, Sep 21, 2017 at 9:20 PM, Nick Coghlan wrote: > >>> one_tenth = 0x1.0 / 0xA.0 > >>> two_tenths = 0x2.0 / 0xA.0 > >>> three_tenths = 0x3.0 / 0xA.0 > >>> three_tenths == one_tenth + two_tenths > False > OMG Regardless of whether we introduce this feature, .hex() is the w

Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread David Mertz
> > Unrelated thought: Users might be unsure if the exponent in a hexadecimal > float is in decimal or in hex. I was playing around with float.fromhex() for this thread, and the first number I tried to spell used a hex exponent because that seemed like "the obvious thing"... I figured it out qui

Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread Rhodri James
On 22/09/17 03:57, David Mertz wrote: I think you are missing the point I was assuming at. Having a binary/hex float literal would tempt users to think "I know EXACTLY what number I'm spelling this way"... where most users definitely don't in edge cases. Quite. What makes me -0 on this idea is

Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread Serhiy Storchaka
21.09.17 18:23, Victor Stinner пише: My vote is now -1 on extending the Python syntax to add hexadecimal floating literals. While I was first in favor of extending the Python syntax, I changed my mind. Float constants written in hexadecimal is a (very?) rare use case, and there is already float.

Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread Antoine Pitrou
On Thu, 21 Sep 2017 22:14:27 -0500 Tim Peters wrote: > [David Mertz ] > > -1 > > > > Writing a floating point literal requires A LOT more knowledge than writing > > a hex integer. > > But not really more than writing a decimal float literal in > "scientific notation". People who use floats are

Re: [Python-ideas] Hexadecimal floating literals

2017-09-22 Thread Rob Cliffe
On 22/09/2017 02:32, Steven D'Aprano wrote: Are there actually any Python implementations or builds which have floats not equal to 64 bits? If not, perhaps it is time to make 64 bit floats a language guarantee. This will be unfortunate when Intel bring out a processor with 256-bit floats (