what is difference about numeric 0 and charcter '0'?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

what is difference about numeric 0 and charcter '0'?

Postby helen2000 » Fri Jun 18, 2010 9:08 pm

Hi All,

my understanding is: numeric 0 is 00H, but character '0' is F0H, anybody can tell me if it's right answer in Cobel? thanks,

Helen
helen2000
 
Posts: 80
Joined: Sat Aug 08, 2009 9:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: what is difference about numeric 0 and charcter '0'?

 

Re: what is difference about numeric 0 and charcter '0'?

Postby Robert Sample » Fri Jun 18, 2010 9:25 pm

Well, it depends. COBOL has USAGE DISPLAY, USAGE COMP, USAGE COMP-1, USAGE COMP-2, USAGE COMP-3, USAGE COMP-4 and USAGE COMP-5 numeric variables. The format for a zero is different depending upon the usage clause:
DISPLAY X'F0'
COMP-1 X'40000000'
COMP-2 X'4000000000000000'
COMP-3 X'0C'
COMP X'0000'
also note that the length of the binary (COMP) variable shown is the minimum while the COMP-3 is PIC S9 COMP-3.

Character O (as in the letter between N and P in the alphabet) is X'D6' while the lower case o is X'96'
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: what is difference about numeric 0 and charcter '0'?

Postby helen2000 » Fri Jun 18, 2010 9:38 pm

thanks for your replay, my means is: character zero and numeric zero is the same in CObol? thanks,
helen2000
 
Posts: 80
Joined: Sat Aug 08, 2009 9:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: what is difference about numeric 0 and charcter '0'?

Postby Robert Sample » Fri Jun 18, 2010 10:35 pm

For a USAGE DISPLAY variable, the character zero and the number zero are the same -- F0 in hexadecimal. For any other USAGE, this is not a true statement.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: what is difference about numeric 0 and charcter '0'?

Postby helen2000 » Fri Jun 18, 2010 10:52 pm

AAA Pic x value 0.

how do you know AAA is numeric zero or character zero? thanks, RObert Sample
helen2000
 
Posts: 80
Joined: Sat Aug 08, 2009 9:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: what is difference about numeric 0 and charcter '0'?

Postby Robert Sample » Fri Jun 18, 2010 11:03 pm

In this case you give, it doesn't matter whether AAA is character zero or number zero -- they are treated exactly the same. In fact, you can move AAA to a PIC 9 variable and use it for arithmetic if desired. Technically, AAA is an alphanumeric variable, not a numeric variable, so things like MOVE statements will work differently, depending on the receiving variable, but a variable BBB PIC 9 VALUE ZERO looks exactly the same in a dump -- hexadecimal F0.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: what is difference about numeric 0 and charcter '0'?

Postby helen2000 » Fri Jun 18, 2010 11:58 pm

thank you very much, Mr. RObert sample, It's very clear! :)
helen2000
 
Posts: 80
Joined: Sat Aug 08, 2009 9:44 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post