Page 1 of 1

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

PostPosted: Fri Jun 18, 2010 9:08 pm
by helen2000
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

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

PostPosted: Fri Jun 18, 2010 9:25 pm
by Robert Sample
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'

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

PostPosted: Fri Jun 18, 2010 9:38 pm
by helen2000
thanks for your replay, my means is: character zero and numeric zero is the same in CObol? thanks,

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

PostPosted: Fri Jun 18, 2010 10:35 pm
by Robert Sample
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.

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

PostPosted: Fri Jun 18, 2010 10:52 pm
by helen2000
AAA Pic x value 0.

how do you know AAA is numeric zero or character zero? thanks, RObert Sample

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

PostPosted: Fri Jun 18, 2010 11:03 pm
by Robert Sample
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.

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

PostPosted: Fri Jun 18, 2010 11:58 pm
by helen2000
thank you very much, Mr. RObert sample, It's very clear! :)