develooper Front page | perl.perl5.porters | Postings from November 2000

Re: [PATCH] Is infinity a number?

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
November 29, 2000 07:00
Subject:
Re: [PATCH] Is infinity a number?
Message ID:
20001129150012.G75302@plum.flirble.org
On Wed, Nov 29, 2000 at 02:48:20PM +0000, Simon Cozens wrote:
>  perl -we 'print 0+"infinity"'
> tells me that:
>  Argument "infinity" isn't numeric in addition (+) at -e line 1.
> But then it treats it like a number, instead of zero:
>  inf
> 
> I believe that this warning is spurious.

Does your sv.c look like this:

    else if (*s == 'I' || *s == 'i') {
	s++; if (*s != 'N' && *s != 'n') return 0;
	s++; if (*s != 'F' && *s != 'f') return 0;
	s++; if (*s == 'I' || *s == 'i') {
	    s++; if (*s != 'N' && *s != 'n') return 0;
	    s++; if (*s != 'I' && *s != 'i') return 0;
	    s++; if (*s != 'T' && *s != 't') return 0;
	    s++; if (*s != 'Y' && *s != 'y') return 0;
	    s++;
	}
	sawinf = 1;
    }


with that last s++; after the Y y line?
I thought I'd cured part of this. (ie "inf" and "infinity" behave the same way
now.)
Do "inf" and "infinity" behave in exactly the same way for whether perl
binary you just ran that test on?

However, I found that atof()'s handling of the string "infinity" differed:
glibc2 on linux and "infinity" because a floating point inf.
FreeBSD's clib took the string "infinity" to be a floating point 0.

Which OS (or OSes) was your example on?

(I'm not claiming to know what's going on, just that I have enough evidence
with two x86 OSes that whatever is going on is non-portable)

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About