<br><br><div class="gmail_quote">On Sun, Feb 7, 2010 at 6:22 AM, duncan smith <span dir="ltr"><<a href="mailto:buzzard@urubu.freeserve.co.uk">buzzard@urubu.freeserve.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Hello,<br>
      I'm trying to find a clean and reliable way of uncovering information about 'extremal' values for floats on versions of Python earlier than 2.6 (just 2.5 actually).  I don't want to add a dependence on 3rd party modules just for this purpose.  e.g. For the smallest positive float I'm using,<br>


<br>
<br>
import platform<br>
if platform.architecture()[0].startswith('64'):<br>
    TINY = 2.2250738585072014e-308<br>
else:<br>
    TINY = 1.1754943508222875e-38<br></blockquote><div><br>The above code is executed on OSX (snow leopard - 64 bit) without any issue.  Your implementation seems fine to me.<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


<br>
<br>
where I've extracted the values for TINY from numpy in IDLE,<br>
<br>
<br>
>>> float(numpy.finfo(numpy.float32).tiny)<br>
1.1754943508222875e-38<br>
>>> float(numpy.finfo(numpy.float64).tiny)<br>
2.2250738585072014e-308<br>
>>><br>
<br>
<br>
I'm not 100% sure how reliable this will be across platforms.  Any ideas about the cleanest, reliable way of uncovering this type of information?  (I can always invoke numpy, or use Python 2.6, on my home machine and hardcode the retrieved values, but I need the code to run on 2.5 without 3rd part dependencies.)  Cheers.<br>


<br>
Duncan<br><font color="#888888">
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>