Skip to Main Content
IBM Z Software


This portal is to open public enhancement requests against IBM Z Software products. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Not under consideration
Workspace PL/I Compilers
Created by Guest
Created on May 12, 2017

Correct Picture Representation of Floating Point Numbers

When using picture specification to display a floating point number field, (for example P'(15)S9V.(4)9' output for a FLOAT DEC(16) variable), the output is not always accurate. The decimal portion is frequently wrong. For example, a number ending in ".57" might be reported as ".5699" We have to convert the floating point variables to a fixed decimal variable, then display the fixed decimal number to get an accurate report. We'd prefer not to have to do this.

FD: PROCEDURE;

DECLARE
BUFFER CHAR(80) VARYING,
FLTFLD1 FLOAT DEC(16) INIT(15000.57),
FLT2PCKA ENTRY(*,*,FIXED BIN(31), FIXED BIN(31))
OPTIONS(ASM INTER),
PCKNUM194 FIXED DEC(19,4) INIT(0),
FW4 FIXED BIN(31) INIT(4),
FW10 FIXED BIN(31) INIT(10);

PUT STRING(BUFFER) EDIT
('SHARES= ',FLTFLD1)
((1)A,P'(15)S9V.9999');

PUT FILE(SYSPRINT) EDIT
(BUFFER)
(COL(2),A,SKIP);

CALL FLT2PCKA(FLTFLD1,PCKNUM194,FW10,FW4);

PUT STRING(BUFFER) EDIT
('SHARES= ',PCKNUM194)
((1)A,P'(15)S9V.9999');

PUT FILE(SYSPRINT) EDIT
(BUFFER)
(COL(2),A,SKIP);

END FD;

OUTPUT:
SHARES= +15000.5699
SHARES= +15000.5700

Can the accuracy of the picture display be improved for floating point variables?

Idea priority Medium
  • Guest
    Reply
    |
    Jun 8, 2017

    this is an inherent problem in using hex (or binary) float to represent decimal values: the representation will be inexact. You can even prove that one cannot represent 1/5 (and hence 1/10) exactly as a finite binary fraction.

    There is, however, already a solution to this problem: use Decimal Floating Point (aka DFP). It is available via the FLOAT(DFP) compiler option

  • Guest
    Reply
    |
    Jun 7, 2017

    Or, if IBM does not want to impact existing functionality, can a new picture format be added that will instruct the compiler to do the conversion to packed as part of the display? F2P'(15)S9V.9999'.

    PUT STRING(BUFFER) EDIT
    ('SHARES= ', FLTFLD1)
    ((1)A, F2P'(15)S9V.9999');

  • Guest
    Reply
    |
    May 13, 2017

    "... Can the accuracy of the picture display be improved for floating point variables?"

    As you've already found out yourself, the ***only*** way to display floating point variables the way you want is to convert them into fixed point first.

    Except for "a few" floating point values, most floating point variables ***cannot*** exactly be represented, not in IBM HEX format, nor in IEEE (754) floating point.

    Any changes to the compiler, unless a new RULES() option is introduced would break numerous other programs - you may want to see 0.5700, whereas Tom, Dick or Harry absolutely require 0.5699...