ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Converting character to ASCII

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

  • Converting character to ASCII

    Does anyone know how I convert this numeric 1291.12-
    into 000012911K? I believe that is the ASCII value of the 1291.12 number.

    Thanks,

    DAC

  • #2
    Re: Converting character to ASCII

    Originally posted by dcutaia View Post
    Does anyone know how I convert this numeric 1291.12-
    into 000012911K? I believe that is the ASCII value of the 1291.12 number.

    Thanks,

    DAC
    Well the ASCII value would normally be expressed in hex so I'm assuming you mean the character equivalent.

    We're talking RPG here so it would be EBCDIC anyway so I'm really confused by the question.

    Anyway - assuming what you meant was character format then the answer is simple. (Code format not correct).
    Code:
    D MyCharVersion   DS
     // Note the "S" data type must be used or this will not work
    D  MyNumVersion                           10s 2
    
    D InputNumber                             10p 2  Inz(-1291.12)
    
     /Free
    
      MyNumVersion = InputNumber;   // Assuming source is zoned or packed
      // MyCharVersion now contains the required characters
    
      // If input is character then
    
      MyNumVersion = %Dec('-1291.12');

    Comment

    Working...
    X