Showing content from http://mail.python.org/pipermail/python-dev/attachments/20080626/ef2c536a/attachment.htm below:
<div class="gmail_quote">On Thu, Jun 26, 2008 at 9:30 PM, "Martin v. Löwis" <<a href="mailto:martin@v.loewis.de">martin@v.loewis.de</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">> Answering for myself: because it gives an exact representation of a<br>
> floating-point number in a fairly human-readable format.<br>
<br>
</div>Ok. But<br>
<br>
py> binascii.hexlify(struct.pack("d", 3.14))<br>
'1f85eb51b81e0940'<br>
<br>
does that already, no? You won't know the precise value, but you won't<br>
know that with hex support, either.<br>
<div class="Ih2E3d"></div></blockquote><div><br></div><div>The output from hex_float(3.14) would be something like:</div><div><br></div><div>'0x1.91eb851eb851fp+1'<br></div><div><br></div><div>The exponent is still usually given in decimal; there's no need</div>
<div>for it to be hexadecimal for exactness.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I'd question that the user is able to make sense of a number when<br>
mantissa and exponent is represented in hex.<br>
<div class="Ih2E3d"></div></blockquote><div><br></div><div>I think the above it still a bit easier to understand than</div><div>if one has to figure out where the sign/exponent and</div><div>exponent/fraction bit boundaries are, unbias the exponent,</div>
<div>and add the extra hidden '1' bit into the mantissa. That's</div><div>a lot of mental work.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Then I'd argue that the feature should be symmetric: If there is<br>
support for printing floating point numbers as hex, there should<br>
also be support for hex floating point literals.<br></blockquote><div><br></div><div>I agree with this. Or at least support for hex floating point</div><div>strings, if not literals.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Also, to follow C's tradition, it would be better if that was<br>
*not* integrated into the hex function (or a hex method), but<br>
if there was support for %a in string formatting.<br></blockquote><div><br></div><div>I'd be delighted with '%a' support.</div><div><br></div><div>Mark</div><div><br></div></div>
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4