mainframepl-i

Why comparision doesn't work as I suspect? PL/I


This comparison prints '0'b. Don't understand why... As I know strings are converted automatically to float in PL/I if needed.

put skip list('-2.34e-1'=-2.34e-1);

Solution

  • I have tested this in our environment (Enterprise PL/I V4.5 on z/OS) and found the same behaviour - under certain compile-options.

    Using the option FLOAT(NODFP) (i.e. do not use native support for decimal floating point, I think the option was introduced with Enterprise PL/I V4.4) the following happens:

    Under FLOAT(DFP) (i.e. when using the machines DFP support)

    So your problem is a combination of the compilers different choice of data-representation and resulting rounding-errors from using binary floating point of different precision.