Page 3 of 3

Re: how to convert string to number?

PostPosted: Thu Mar 18, 2010 2:41 am
by helen2000
hi, Mr. RObert and Dick, I got the dump output. which R10 is what I wanted for " mvc 48(6,8), 186(10)" or "move '9754' to num0",
there are a couple of R10s, I confused here.
 +000024  R4....... 0F69DECC  R5....... 00017038  R6....... 2960B2E8  R7..
 +000038  R9....... 00029116  R10...... 00028117  R11...... 0F699140  R12.
 +00004C  NAB...... 0002A210  PNAB..... 00000000  reserved. 00000000  0000
 +000064  reserved. 00000000  reserved. 00000000  MODE..... 8F69D2F2  rese
 +000078  reserved. 00000000  reserved. 00000000                         
SA for H2DCBL: 00027018                                                   
 +000000  FLAGS.... 0010      member... 4001      BKC...... 00022518  FWC.
 +000010  R15...... A965E978  R0....... 00027118  R1....... 29600E81  R2..
 +000024  R4....... 29600AE0  R5....... 00020910  R6....... 00000000  R7..
 +000038  R9....... 29692100  R10...... 29600BD0  R11...... 29600F1C  R12.
 +00004C  NAB...... 00027118  PNAB..... 00000000  reserved. 00000000  2969
 +000064  reserved. 00000000  reserved. 00000000  MODE..... 00000000  rese
 +000078  reserved. 00000000  reserved. 00000000                         
IB for H2DCBL: 00027A10                                                   



the soruce code is :

 01  WS-PGM-COUNTER.                                           
      03 NUM0                           PIC X(6).             
      03 NUM1                           PIC 9(06).             
*     03 FILLER  REDEFINES  NUM1        PIC X(6).             
      03 NUM2                           PIC 9(06) VALUE 9754. 
      03 DISPNUM                        PIC S9(4).             
      03 PNUM           PIC S9(5) PACKED-DECIMAL.             
      03 BNUM           PIC S9(4) BINARY.                     

...........
 MOVE '9754' TO NUM0           
 MOVE NUM0 TO NUM1             
 IF NUM1 = NUM2                 
     DISPLAY "SUCCESSFUL!"     
 ELSE                           
     DISPLAY "CONVERSION FAIL!"
 END-IF                         
 DISPLAY 'NUM0=' NUM0           
 DISPLAY 'NUM1=' NUM1           
 DISPLAY 'NUM2= ' NUM2         
 MOVE 2 TO DISPNUM             
           PNUM                 
           BNUM                 
 ADD 1 TO WS-VAR2.             
 GOBACK.                       
 DISPLAY 'DISPNUM= ' DISPNUM   
 DISPLAY 'PNUM= ' PNUM         

and relative assemble code:
000106  MOVE                                                                 
   0005F6  D205 8030 A0BA          MVC   48(6,8),186(10)         NUM0       
000107  MOVE                                                                 
   0005FC  D205 8036 8030          MVC   54(6,8),48(8)           NUM1       
   000602  96F0 803B               OI    59(8),X'F0'             NUM1+5     
000108  IF                                                                   
   000606  F235 D0F0 8036          PACK  240(4,13),54(6,8)       TS2=0       
   00060C  960F D0F3               OI    243(13),X'0F'           TS2=3       
   000610  F235 D0F8 8040          PACK  248(4,13),64(6,8)       TS2=8       
   000616  960F D0FB               OI    251(13),X'0F'           TS2=11     
   00061A  D503 D0F0 D0F8          CLC   240(4,13),248(13)       TS2=0       
   000620  4770 B1BE               BC    7,446(0,11)             GN=7(000632)
000109  DISPLAY                                                             
   000624  58F0 202C               L     15,44(0,2)              V(IGZCDSP )
   000628  4110 A2FF               LA    1,767(0,10)             PGMLIT AT +7
   00062C  05EF                    BALR  14,15                               
   00062E  47F0 B1C8               BC    15,456(0,11)            GN=8(00063C)
   000632                 GN=7     EQU   *                                   


thanks,
Helen

Re: how to convert string to number?

PostPosted: Thu Apr 29, 2010 2:36 pm
by barrybert
This Java tip illustrates a method of converting a string to a number. This tip is very useful for developer who are expecting a number as a input but recieve the number in a string format. Developers may use this code to convert the retrieved string into number format.
byte b = Byte.parseByte("123");
short s = Short.parseShort("123");
int i = Integer.parseInt("123");
long l = Long.parseLong("123");
float f = Float.parseFloat("123.4");
double d = Double.parseDouble("123.4e10");

Re: how to convert string to number?

PostPosted: Fri Apr 30, 2010 2:51 am
by dick scherrer
Hello,

Developers may use this code to convert the retrieved string into number format.
Not in a COBOL program. . .

Why post a non-cobol reply to a specifically cobol question?


Helen,

This topic slipped by - do you have what you need now?

d