[Python-ideas] Hexadecimal floating literals
Tim Peters
tim.peters at gmail.com
Fri Sep 22 13:15:51 EDT 2017
More information about the Python-ideas mailing list
Fri Sep 22 13:15:51 EDT 2017
- Previous message (by thread): [Python-ideas] Hexadecimal floating literals
- Next message (by thread): [Python-ideas] Hexadecimal floating literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Antoine Pitrou <solipsis at pitrou.net>] > ... > 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 understand both hex and (decimal) scientific notation, learning what hex float notation means is easy. > So for someone reading code, the scientific notation poses no problem > as they understand it intuitively (even if they may not grasp the > difficulties of the underlying conversion to binary FP), while for > hexadecimal float notation need they have to go out of their way to > learn about it, parse the number slowly and try to make out what its > value is. 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. Same for hex float notation. Of course it's true that many (not all) people do know about hex integers and/or decimal scientific notation from prior (to Python) experience. My objection is that we already have a way to use hex float notation, and the _need_ for it is rare. If someone uninitiated sees a rare: x = 0x1.aaap-4 they're going to ask on StackOverflow what the heck it's supposed to mean. But if they see a rare: x = float.fromhex("0x1.aaap-4") they can Google for "python fromhex" and find the docs themselves at once. The odd method name makes it highly "discoverable", and I think that's a feature for rare gimmicks with a small, specialized audience.
- Previous message (by thread): [Python-ideas] Hexadecimal floating literals
- Next message (by thread): [Python-ideas] Hexadecimal floating literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list