Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Reverse Built in function for %CHAR

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

  • Reverse Built in function for %CHAR

    I know how to use %CHAR. But I am looking for a way to use a built in fucntion which converts the Character to Numeric. Well, I can use simple move, but my data is embedded with in a large text. So, I want to substring it and convert it to Numeric like Eval Number = %Numeric(%Subst(Text:2:5) Where Numeber = (3,0) Unfortunately there is nothing called %Numeric Or Do I have to do the RPG III Way ?? Thanks Rahul

  • #2
    Reverse Built in function for %CHAR

    Rahul, Use the Search Facility for this. I answered last week about this and using the bif %DEC(field). Barbara Morris pointed out that this is a future request and that I had misread a statement in a manual. She does however point out a way of doing this, which will take an alpha field with formatted numeric (123,456.78-) and convert it to 12345678 for use as a numeric field. This may have been only for formatted fields however, so please read her comments. -bret

    Comment


    • #3
      Reverse Built in function for %CHAR

      I am doing this in an ILE/RPG program using the C function atof(). The code looks as follows. D atof PR 8F extproc('atof') D alpha * value options(*string) Eval NumField = atof(%trim(CharField)) I dont know this will help you or not.

      Comment


      • #4
        Reverse Built in function for %CHAR

        'atof' occasionally gives the wrong result. This is because it uses floating point, and floating point can't correctly represent all decimal values. Watch out: 'atof' often gives the wrong result if you don't use (H) on your eval. Barbara

        Comment


        • #5
          Reverse Built in function for %CHAR

          >'atof' occasionally gives the wrong result. Why not use C function 'atoi'? (converts character to integer)

          Comment

          Working...
          X