-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks to the documentation pointers.  For whatever it's worth, I just
whipped this up in perl.  If anyone else finds it useful, feel free.

- -- Pat

#
# Parse a binary number in s390 E format, Hexidecimal Floating Point
# (HFP) short.
#
# as documented in "Principles of Operation" chapter 18
#
# Parameters:
#   32 bits of raw data, easiest obtained by "unpack ("L", ...)"
#
# Return:
#   A perl native number
#
sub parse_E ($) {
    my $data = shift;

    my ($sign, $characteristic, $fraction);
    $sign = $data & 0x80000000;
    $sign = $sign ? -1 : 1;

    $characteristic = (($data & 0x7F000000) >> 24) - 64;

    $fraction = (($data & 0x00ffffff) / 0xffffff) * 16;

    my $num = $sign * $fraction ** $characteristic;

    printf("DEBUG: parse_E(0x%x) sign: %d charisteristic: %d ".
           "fraction: 0x%x %f = %f\n",
           $data, $sign, $characteristic, $fraction,
           $fraction, $num);

    return $num;
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAklACDAACgkQNObCqA8uBsx69gCdHUgIfZ6+JX8uVawG37+6Shuw
URIAn1bXccOc3d8ftZcJC2qd5hwHKUmZ
=LJDj
-----END PGP SIGNATURE-----

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to