Subject: | |
From: | |
Reply To: | |
Date: | Tue, 11 Jun 2002 12:15:36 -0400 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
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 *
|
|
|