infinity
Tim Peters
tim at zope.com
Wed Oct 9 16:26:06 EDT 2002
[Gregor Lingl]
> I observed:
>
> >>> 1e308
> 1e+308
> >>> 1e309
> 1.#INF
> >>> 1e308*10
> 1.#INF
> >>> type(1e308*10)
> <type 'float'>
> >>> -1e309
> -1.#INF
> >>>
This output will vary across platforms; it depends on how your platform C
library feels like spelling infinity (if it supports it at all, that is).
> Is there a token or a name to input
> this strange float object,
> __repr__esented by 1.0#INF
> directly? For instance as follows:
>
> def fun(a, mini=-?1.?INF? , maxi = ?1.?INF?):
> ....etc...
No. Python proper knows nothing about this; any behavior you see in its
presence is a platform-dependent accident. On *some* platforms the string
produced can be parsed again by float(), but again that's up the platform C
library. It looks to me like you're using Windows, and Windows cannot eat
its own output for infinity (or NaN).
More information about the Python-list
mailing list