Front page | perl.perl6.language |
Postings from October 2001
Re: NaN semantics
Thread Previous
From:
RaFaL Pocztarski
Date:
October 11, 2001 04:30
Subject:
Re: NaN semantics
Message ID:
3BC58183.1645FA6F@rfl.pl
David Nicol wrote:
> RaFaL Pocztarski wrote:
> > Or maybe NaN evaluates to 'NaN' in string context and
> > +$x eq 'NaN' (or +$x eq NaN) could be used? NaN==NaN being false is in
> > fact very intuitive for me, as NaN is something without any numerical
> > meaning, so numerically compared to anything doesn't make sense (as ==
> > means numerical equality, not just equality). Maybe it should be undef
> > instead of false?
>
> I'm coming to this thread after nearly a week of everyone weighing in
> their opinions, and fully expect to see what I'm about to type in
> stated by someone else, days ago, a little further down the long list
> of posts.
Actually you have just quoted me when I said that.. :)
> What if not-a-number stringifies to NaN, but numerically always compares
> to false, so the conditional in the example could CLEARLY be written
>
> while $inflation ne NaN;
It should be:
while +$inflation ne NaN;
because $inflation itself can be (and probably is) some other string
than 'NaN', so +$inflation evaluates to NaN, and when ne operator
provides a string context it then evaluates to 'NaN'.
- RaFaL Pocztarski, admin@rfl.pl
Thread Previous