loody wrote:
Dear all:

Hello,

I have to compare 2 values which is represented by 2 bytes as 0xffff
and 0x00fe in 2's complement system.
so the difference between them should be -1 - 254 =-255.
but before do such calculation, I have to translate 0xffff as -1.
Is there build-in function in perl for me to use, or should I transfer
it by hand?

$ perl -le'$x = 0xffff; print $x; print unpack "s", pack "S", $x'
65535
-1


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to