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

Re: op/arith.t

Thread Previous
From:
Norton Allen
Date:
July 6, 2001 13:31
Subject:
Re: op/arith.t
Message ID:
200107062038.QAA04861@bottesini.harvard.edu
Nicholas Clark wrote:
> 
> 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?

  Yep, I tried that already.

> 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"]

  Results as you expect. I agree with your suspicions.

> 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

  I'll take a look. -Norton
  

Thread Previous


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