max / min / smallest float value on Python 2.5

Shashwat Anand anand.shashwat at gmail.com
Sun Feb 7 02:17:34 CET 2010


On Sun, Feb 7, 2010 at 6:22 AM, duncan smith
<buzzard at urubu.freeserve.co.uk>wrote:

> Hello,
>      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,
>
>
> import platform
> if platform.architecture()[0].startswith('64'):
>    TINY = 2.2250738585072014e-308
> else:
>    TINY = 1.1754943508222875e-38
>

The above code is executed on OSX (snow leopard - 64 bit) without any
issue.  Your implementation seems fine to me.

>
>
> where I've extracted the values for TINY from numpy in IDLE,
>
>
> >>> float(numpy.finfo(numpy.float32).tiny)
> 1.1754943508222875e-38
> >>> float(numpy.finfo(numpy.float64).tiny)
> 2.2250738585072014e-308
> >>>
>
>
> 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.
>
> Duncan
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100207/ef79bf51/attachment.html>


More information about the Python-list mailing list