On Fri, Jan 9, 2015 at 1:12 PM, Ian Kelly wrote:
> Or to never have to worry about it:
>
> INF = 1e400
> while not math.isinf(INF):
> INF *= INF
With no imports whatsoever:
inf = 1e400
nan = inf-inf
while nan == nan:
inf *= inf
nan = inf-inf
But now we're getting stupid :)
ChrisA
-
On Thu, Jan 8, 2015 at 7:07 PM, Chris Angelico wrote:
> On Fri, Jan 9, 2015 at 12:46 PM, Steven D'Aprano
>> The fallback rule I use when float('nan') fails is
>>
>> INF = 1e3000 # Hopefully, this should overflow to INF.
>> NAN = INF-INF # And this hopefully will give a NaN.
>
> The first
On Fri, Jan 9, 2015 at 12:46 PM, Steven D'Aprano
wrote:
> Chris Angelico wrote:
>
>> On Fri, Jan 9, 2015 at 1:50 AM, Jussi Piitulainen
>> wrote:
>>>>>> 0*1e400
>>>nan
>>
>> Nice, that's shorter than mine.
>
> I'm not entirely sure, but I suspect that 0*1e400 may not be quite as
> portable
Chris Angelico wrote:
> On Fri, Jan 9, 2015 at 1:50 AM, Jussi Piitulainen
> wrote:
>>>>> 0*1e400
>>nan
>
> Nice, that's shorter than mine.
o_O
Is that really the sort of thing you should be revealing here?
Oh wait, you're talking about code...
I'm not entirely sure, but I suspect tha
Chris Angelico writes:
> On Fri, Jan 9, 2015 at 1:37 AM, Marko Rauhamaa wrote:
> >
> > True, but that got me thinking: what standard Python math
> > operation evaluates to NaN?
>
> Subtracting infinity from infinity is one easy way.
>
> >>> 1e309
> inf
> >>> 1e309-1e309
> nan
I managed to get in
On Fri, Jan 9, 2015 at 1:50 AM, Jussi Piitulainen
wrote:
>>>> 0*1e400
>nan
Nice, that's shorter than mine.
ChrisA
--
https://mail.python.org/mailman/listinfo/python-list
Marko Rauhamaa writes:
> Ian Kelly:
>
> > To get nan as a literal just do:
> >
> > nan = float("nan")
>
> True, but that got me thinking: what standard Python math operation
> evaluates to NaN?
All manner of arithmetics gives overflow errors ("Numerical result out
of range") but a literal wi
On Fri, Jan 9, 2015 at 1:37 AM, Marko Rauhamaa wrote:
> Ian Kelly :
>
>> To get nan as a literal just do:
>>
>> nan = float("nan")
>
> True, but that got me thinking: what standard Python math operation
> evaluates to NaN?
Subtracting infinity from infinity is one easy way.
>>> 1e309
inf
>>>
Ian Kelly :
> To get nan as a literal just do:
>
> nan = float("nan")
True, but that got me thinking: what standard Python math operation
evaluates to NaN?
Marko
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, Jan 9, 2015 at 1:15 AM, maurog wrote:
> I'm running some pandas examples and I canno find in what module NaN is
> defined. Does anyone know what module I have to import in order to have
> it defined?
It's simply float("nan"). If you want a name, you can give it one:
NaN = float("nan")
#
On Thu, Jan 8, 2015 at 7:15 AM, maurog wrote:
> I'm running some pandas examples and I canno find in what module NaN is
> defined. Does anyone know what module I have to import in order to have
> it defined?
It's not defined anywhere. To get nan as a literal just do:
nan = float("nan")
--
h
I'm running some pandas examples and I canno find in what module NaN is
defined. Does anyone know what module I have to import in order to have
it defined?
--
https://mail.python.org/mailman/listinfo/python-list
12 matches
Mail list logo