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

Strange perls behaviour (a question)

Sergey V. Kolychev
February 18, 2000 09:31
Strange perls behaviour (a question)
Message ID:
Good day.

I got an interesting case with perl 5.004 i386 Linux Redhat 5.0
I have some xs module (Net::RawIP) and using 
the  following statement in xsub.
u_int32_t value = SvIV(sv) ,  very simple.
The weirdness is that perl makes a  difference from a variable 
that is hardcoded in the  script and one given to it by a shell as a
$a = 4294967295; # 2**32 -1
In the xs I get unsigned int 4294967295.
$a = $ARGV[0];
./ 4294967295
In the xs I get int of 0x7FFFFFFF.
$a = ~0 - (~0 - $ARGV[0]);
./ 4294967295
In the xs I get unsigned int 4294967295.
In all of these ways if I trying to print $a then perl prints 4294967295.

If somebody would like to answer ( I know you all are very busy people),
then please answer by e-mail. I am not in the list.

Have a nice day.

   ----------------------Alchevsk Linux User Group-----------------------
      I don't call, I don't cry , I don't apologize
      All will be gone like a apple tree's white smoke... (S.Esenin) | e-mail:
      PGP key: finger Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About