develooper Front page | perl.perl5.porters | Postings from July 2001

Re: op/arith.t

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
July 6, 2001 13:21
Subject:
Re: op/arith.t
Message ID:
20010706212151.W59620@plum.flirble.org
On Fri, Jul 06, 2001 at 03:38:36PM -0400, Norton Allen wrote:
> Under Neutrino, I'm failing a test in op/arith.t.
> The crux of the matter is:
> 
>   perl -e '$x = 8589934590; print $x, "\n"'
> 
> produces '4294967294' (i.e. garbage). Where/how is that
> large constant converted to an integer?

toke.c:#if defined(Strtol) && defined(Strtoul)
toke.c:         iv = Strtol(PL_tokenbuf, (char**)NULL, 10);
toke.c:    Strtol() and Strtoul() are used above.

I think, but I've not looked closed for some weeks.

What do 
perl -e '$x = "8589934590"; print $x + 0, "\n"'
and
perl -MPOSIX -e '$! = 0; $x = strtol("8589934590"); print "$!\n"'

give you?

My hunch is that your strtol isn't setting errno correctly.
[If this is right I'd expect my first to produce 8589934590 because runtime
conversion is now done by Perl_grok_number in numeric, and the second NOT
to return "Numerical result out of range"]

If so you may want to see how uts/strtol_wrap.c is used.
However, I think the long term (eg next 24 hours?) solution is to make
toke.c use Perl_grok_number

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