Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Problems with pack. Keywords: pack,unpack,unsigned Message-ID: <7471@jpl-devvax.JPL.NASA.GOV> Date: 20 Mar 90 00:58:23 GMT References: <3105@jupiter.oakhill.UUCP> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 28 In article <3105@jupiter.oakhill.UUCP> billl@oakhill.UUCP (Bill Ledbetter) writes: : $[ = 1; : : $lw[1] = hex("01234567"); : $lw[2] = hex("89abcdef"); : $binI = pack("I2", @lw); : @newI = unpack("I2", $binI); : : # Prints out "01234567 00000000" : printf "%08x %08x\n", $newI[1], $newI[2]; : : $bini = pack("i2", @lw); : @newi = unpack("i2", $bini); : : # Prints out "01234567 89abcdef" : printf "%08x %08x\n", $newi[1], $newi[2]; : : ------ : : This seems to be counter-intuitive. Is this a bug, or am I doing something : really stupid... It's a bug on someone's part--but we're not sure who. It seems that Sun won't let you cast a negative floating point number to an unsigned integer. While there's something to be said for this viewpoint, compatibility with other machines ain't one of them. I'm working on the problem. Larry