ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

did the decimal point go?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • did the decimal point go?

    Simple but frustrating...

    I have this RPGLE code:
    H

    Dnum3 S 20P 6

    /free
    num3 = 16 + 14.5 + 27.2;
    DSPLY num3;
    /end-free

    *inlr = *on;

    I am expecting 57.7 to display, instead I get 5,770....

    I am writing another PGM that pulls decimal numbers from tables with embedded SQL. Then I am trying to get percentages....the numbers are all correct, but missing their decimal positions when displayed (during testing). So I created just this simple math to test the decimal disappearance...

    What the heck?

  • #2
    Have you tried editing the output (e.g. %EDITC)?

    Comment


    • #3
      I don't plan on doing a PRTF for this pgm, it is simply going to pass it's results to another pgm to do some other stuff. But I like to test the SQL results and instead of seeing 99.54% I am seeing 9954 when I use DSPLY just to see where I am....can't pass that along..

      But I appreciate the response

      Comment


      • jtaylor___
        jtaylor___ commented
        Editing a comment
        I assume you're replying to me, but I'm confused how the PRTF comes into play. Are you saying this "Dsply (%editc(num3 :'1'));" doesn't work?

    • #4
      Use %char to format the number as it looks like DSPLY just shows the digits in the value with no formatting.
      DSPLY %char(num3); will show the 'real' value.

      Comment


      • JonBoy
        JonBoy commented
        Editing a comment
        Yup - what Scott said. DSPLY will not honor decimals etc. when asked to display a numeric. You need to use %Char for simplicity - or %EditC if you want to control the number of decimals displayed.

    • #5
      Thank you...works great

      Comment

      Working...
      X