On Mon, 2008-10-06 at 21:18 +0800, loody wrote: > Dear all: > 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? > below is the method I thought, but it really seems lousy. > > my $tmp_value1="ffee"; > if (hex $tmp_value1 & 0x8000) > { > my $int=int $tmp_value1; > $int -= 2**16; > $tmp_value1=$int; > } > appreciate your help, > miloody >
See `perldoc -f unpack`. -- Just my 0.00000002 million dollars worth, Shawn Linux is obsolete. -- Andrew Tanenbaum -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/