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

Re: [PATCH] Is infinity a number?

Thread Previous | Thread Next
Nicholas Clark
November 29, 2000 07:00
Re: [PATCH] Is infinity a number?
Message ID:
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;
	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
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About