HP3000-L Archives

June 2002, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Michael Abootorab <[log in to unmask]>
Reply To:
Michael Abootorab <[log in to unmask]>
Date:
Tue, 11 Jun 2002 12:15:36 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (53 lines)
Hi,

you are right ( as usual), the correct code follows.
I just want to emphasize that if you are using this code on an
INTEL based processor , beware of byte ordering ( low-endian) and
also sign implementation.

Thanks
Michael



sub pack2dec {

 my $packfield = shift;
 my $num = unpack('H*',$packfield);
 my $sign = 1;

if ( $num =~ /[Ff]/ ){
   $sign = -1;
}

$num =~ s/\D.*//g;

$num = $sign * $num;


return $num;

}


On Tue, 11 Jun 2002 04:16:55 -0500, Dennis Handly <[log in to unmask]>
wrote:

>Michael Abootorab ([log in to unmask]) wrote:
>: the following perl fuction will do the job on HP3000 and HP9000
processors:
>
>Are you sure?
>
>: if ( $num =~ /[FD]/ ){
>:    $sign = -1;
>
>If this is checking for hex F or hex D, it should only check for hex D.
>Hex F is unsigned.
>
>* To join/leave the list, search archives, change list settings, *
>* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2