
PROBLEM:  (QAR #51274, SPR:HPAQC0X4J)  (Patch ID: OSF425-410112)
********
    The multiplication of 2 single precision floating point numbers in ieee
    mode when the result prior to rounding is the largest denormal will
    cause the IEEE emulator to fail with the message:

    FATAL IEEE FLOATING POINT EMULATION ERROR:
    unf:  "UNEXPECTED 2nd execution calls underflow"

Compile the following program with the command
"cc  -float -ieee emerror.c -o emerror":
#include <stdio.h>
 /* This code causes the IEEE emulator to fail with the
  * message indicated below:
  FATAL IEEE FLOATING POINT EMULATION ERROR:
  floating_underflow:  "UNEXPECTED 2nd execution calls underflow"
  * The -ieee and either (-float  or -std1 ) switch is imperative.
  * cc -ieee -float emerror.c -o emerror
  */
 main(){
     float fr,fi,gi,gr,ci;
     sscanf("0 80020c18 bf7fffff 80800000", "%x%x%x%x", &fr, &gi, &fi, &gr);
     printf("%s=%18.9e (%08x)\n","fr",fr,*(int*)&fr);
     printf("%s=%18.9e (%08x)\n","gi",gi,*(int*)&gi);
     printf("%s=%18.9e (%08x)\n","fi",fi,*(int*)&fi);
     printf("%s=%18.9e (%08x)\n","gr",gr,*(int*)&gr);
     ci = fr*gi + fi*gr;
     printf("%s=%18.9e (%08x)\n","ci",ci,*(int*)&ci);
 }
Results before applying the patch:
fr=   0.000000000e+00 (00000000)
gi=  -1.880094124e-40 (80020c18)
fi=  -9.999999404e-01 (bf7fffff)
gr=  -1.175494351e-38 (80800000)
FATAL IEEE FLOATING POINT EMULATION ERROR:
unf:  "UNEXPECTED 2nd execution calls underflow"
   pc:    0xfffffc000060e368
  ins: 0x20001274
  op1: 0x5ad9b01a
  op2: 0x800000000Killed

Results after applying the patch: (a kernel reboot is necessary)
fr=   0.000000000e+00 (00000000)
gi=  -1.880094124e-40 (80020c18)
fi=  -9.999999404e-01 (bf7fffff)
gr=  -1.175494351e-38 (80800000)
ci=   1.175494351e-38 (00800000)

PROBLEM: (QAR 36464,47097,47168,50937,60304) (PatchID: OSF425-245)
********
This patch fixes a problem where programs that do multiplications or divisions
using or producing denormalized values would experience incorrectly rounded
results.

The following program (compiled with the -ieee option) demonstrates the
rounding problem:

------------- test_denorm_mul.c --------------
main () {e with cc -ieee test_denorm_mul.c */
    long xval = 0x1e7ee00000000000;
    long yval = 0x2180101010101010;
    long zval = 0x000f7f7f7f7f7f7f;
    double x = *(double *)&xval;
    double y = *(double *)&yval;
    double z = *(double *)&zval;
    double result = x * y;
    if (result != z) {
        printf ("Denormalized rounding failed:\n");
        printf("  result is %25.15lg\t%16.16lx\n", result, *(long *)&result);
        printf("  should be %25.15lg\t%16.16lx\n", z, *(long *)&z);
    } else {
        printf ("Passed.\n");
    }
}
---------- end of test_denorm_mul.c ------------

When compiled:
    $ cc -ieee test_denorm_mul.c
and run:
    $ a.out
a system without the patch will display:

    Denormalized rounding failed:
      result is     2.15526761980894e-308   000f7f7f7f7f7f80
      should be     2.15526761980894e-308   000f7f7f7f7f7f7f

After patching the system, re-running the program should display the message
"Passed".

Note that the accuracy degradation in the failing case can be so slight that
the decimal display of the result looks like the expected value.  
The hexadecimal display, however, shows that the last bit was rounded 
incorrectly.

