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

Re: [MacPerl] Signed Integers getting returned... Heck



How'm I getting signed integers returned. That's the problem... Dunno. On
this specific machine I do a  unpack("I*", $index); and get something like
-12845762 instead 94 (example numbers). I have the same code running under
solaris(both sparc and intel), nt, macperl, and some compile of linux. 'Tis
working everywhere else. Heck.

As for the *... Thought I needed it. Cool! You taught me something, Alan.
Gotta test first. Ain't perl cool.

As far as the determination of the signed vs unsigned... 10 hours of
painful diagnostic hell printing assorted things out of the engine. Finally
saw some returns that made no sense. The result of the unpack should be a
line number. When they were negative, I knew something was weird.

See the diag control at
http://www.infohiway.com/isn/xpm3.cgi

see the unpredicted return at
http://aahha.com/m3.cgi

(Careful, these are development scripts, lifespan may vary)

The first value is the index offset, second value is the line number where
the hit occurs.

Thanks for the reply, make your code good and cool. Again I appreciate the
* insight. Guess I was just being literal.



>>I have a 50 meg datastructure keyed to an index built with unsigned
>>integers. My search recovers a match, looks at the index and gets an
>>unsigned integer which refers to an offset in the 50M db. Unpack the
>>integer, seek the offset in the db, display the record.
>>
>>$offset=unpack("I*",$index);
>>seek(FILE,$offset,0);
>>read(FILE,$record,$length);
>>print $record;
>>
>>rather than returning an unsigned integer, I get the signed value back.
>>Kack! Especially troublesome when I seek the offset.
>
>The following:
>
>#!perl
>$index = pack("I", 66000);
>$offset = unpack("I", $index);
>print $offset;
>
>works in so far as it prints 66000. No sign of a sign here...
>
>But why do you use "I*" (not that it seems to matter)?
>                     ^
>BTW how do you know you're getting _signed_ integers returned?
>
>Regards,
>
>Alan Fry


John-Michael Keyes - jk@infohiway.com
http://www.infohiway.com