[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

re: [MacPerl] Bitwise not operator.



Roger Hill <roger@doghouse.demon.co.uk>
} I've just been trying to do netmask manipulation in MacPerl (5.03r1m)
} There appear to be problems with the bitwise not of certain numbers,
} Specifically, accorind to macperl :-
} 
} ~ffffff00 is 7fffffff
} and
} ~7fffffff is 80000000 (which is correct.)
} 
} Is there something strange going on here to do with the handling
} of signed quantities and coversions? It would be nice if Perl
} behaved as expected :-)
} 
} If this problem is solved by a Macperl upgrade then GAIA.

This works for me under 5.10b2r2:

#!perl

$a = 0x7fffffff;
$b = ~$a;
printf("%x %x\n",$a,$b);
$b = 0xffffff00;
$a = ~$b;
printf("%x %x\n",$b,$a);

which gives:

7fffffff 80000000
ffffff00 ff

So it seems to be working in 68k (Powerbook 165) BigMacPerl.  I just
checked, and it also works like this:

#!perl

$a = 0x7fffffff;
$b = ~0x7fffffff;
printf("%x %x\n",$a,$b);
$b = 0xffffff00;
$a = ~0xffffff00;
printf("%x %x\n",$b,$a);

Maybe it's a PPC problem, or maybe it's been fixed in since 5.03.  Try a
later version and see what you get.

} 
} --------------------------------------------------------------------------------
} Roger Hill                                        aka roger@aeg-post.demon.co.uk
} 
} Call this a sig....:-?
} 
} 
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us