<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Sep 22, 2017 at 8:37 AM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Sep 21, 2017 at 9:20 PM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>>> one_tenth = 0x1.0 / 0xA.0<br>
>>> two_tenths = 0x2.0 / 0xA.0<br>
>>> three_tenths = 0x3.0 / 0xA.0<br>
>>> three_tenths == one_tenth + two_tenths<br>
False<br></blockquote><div><br></div><div>OMG Regardless of whether we introduce this feature, .hex() is the way to show what's going on here:</div><div><br>>>> 0.1.hex()<br>'0x1.999999999999ap-4'<br>>>> 0.2.hex()<br>'0x1.999999999999ap-3'<br>>>> 0.3.hex()<br>'0x1.3333333333333p-2'<br>>>> (0.1+0.2).hex()<br>'0x1.3333333333334p-2'<br>>>> <br></div></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">This shows so clearly that there's 1 bit difference!</div></div></blockquote><div><br></div><div>Thanks! I really should add this example to the math.isclose() docs....</div><div><br></div><div>.hex is mentioned in:</div><div><br></div><div><a href="https://docs.python.org/3/tutorial/floatingpoint.html">https://docs.python.org/3/tutorial/floatingpoint.html</a><br></div><div><br></div><div>but I don't see it used in a nice clear example like this.</div><div><br></div><div>-CHB</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class="gmail-HOEnZb"><font color="#888888"><br></font></span></div><span class="gmail-HOEnZb"><font color="#888888"><div class="gmail_extra"><br>-- <br><div class="gmail-m_-982923581864928920gmail_signature">--Guido van Rossum (<a href="http://python.org/%7Eguido" target="_blank">python.org/~guido</a>)</div>
</div></font></span></div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>