First tiny PerlXS returns signed instead of unsigned? 
Author Message
 First tiny PerlXS returns signed instead of unsigned?

I started fiddling with PerlXS today and ran into a problem.
Basically, this routine takes the four octets of an ip address, then
folds then into an usigned int and returns it. The problem is, when I
print this returned value in Perl, I get a negative number. Here is
the code:

unsigned int
iptonum(o1, o2, o3, o4)
   unsigned int o1;
   unsigned int o2;
   unsigned int o3;
   unsigned int o4;

   PREINIT:
      unsigned int retnum=0;
   CODE:
      retnum=o1;
      retnum<<=8;
      retnum|=o2;
      retnum<<=8;
      retnum|=o3;
      retnum<<=8;
      retnum|=o4;
      RETVAL = retnum;
   OUTPUT:
      RETVAL

Any ideas?

Thanks in advance,

Peter

---
Software Engineer
EarthLink Network

   'Bad cop. No donut.' - Bumper Sticker
   'Those who love wisdom must investigate many things.' - Heraclitus



Wed, 25 Apr 2001 03:00:00 GMT  
 First tiny PerlXS returns signed instead of unsigned?
This problem has been solved. It turns out that the default typemap
that comes with Perl is incorrect, and uses regular integer macros
instead of the unsigned ones for unsigned integers. I am told that
this will be fixed in the next release.

Peter

---
Software Engineer
EarthLink Network

   'Bad cop. No donut.' - Bumper Sticker
   'Those who love wisdom must investigate many things.' - Heraclitus



Fri, 27 Apr 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem: hex() and Unsigned vs. Signed

2. Fatal Unsigned/Signed Arithmetic Problem

3. Soft returns instead of hard returns...

4. Unsigned Char to Unsigned long

5. Return value from backtick command needs to be 32-bit signed

6. atan2 in Math::Complex returns incorrect signs

7. Tk::BrowseEntry - Return index instead of value?

8. Perl 5.001e subroutine returns length of array instead of array

9. Tk::BrowseEntry - Return index instead of value?

10. regexp unexp. returns status instead of pattern

11. XSub returning undef instead of NULL pointer

12. Perl 6 question $# question - dollar sign pound sign

 

 
Powered by phpBB® Forum Software