View previous topic :: View next topic
|
Author |
Message |
vivekbalokhra Warnings : 1 New User
Joined: 15 Jul 2005 Posts: 6
|
|
|
|
How can we define a working storage variable with value x'04' and compare the same, with the variable which is a 1 byte binary ?? |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Simple..
Code: |
01 VAR1 PIC X(01) VALUE X'04'. |
What do you mean by binary here? Variable declared with USAGE COMP are considered as binary in cobol.I am not sure if you mean the same.
This can be used in comparison as
I am not sure if I've answered your concern correctly. |
|
Back to top |
|
|
vivekbalokhra Warnings : 1 New User
Joined: 15 Jul 2005 Posts: 6
|
|
|
|
HI,
ACTUALLY MY QUERY IS THAT ...
1. I HAVE ONE VARIABLE, 'A' WHOSE PIC IS X(01) AND VALU STORED IS 4, AND THATS IS DEFINED AS 1 BYTE BINARY.
2. I HAVE TO DEFINE A VARIABLE IN WORKING STORGE WHOSE VALUE IS X'04' AND TO COMPARE IT WITH 'A'.
CAN I DO THE COMPARISION ??? |
|
Back to top |
|
|
vkphani
New User
Joined: 29 Oct 2003 Posts: 29
|
|
|
|
Quote: |
1. I HAVE ONE VARIABLE, 'A' WHOSE PIC IS X(01) AND VALU STORED IS 4, AND THATS IS DEFINED AS 1 BYTE BINARY.
|
This is not a binary item. If COMP is used then only it is a binary item.
Quote: |
2. I HAVE TO DEFINE A VARIABLE IN WORKING STORGE WHOSE VALUE IS X'04' AND TO COMPARE IT WITH 'A'.
CAN I DO THE COMPARISION ??? |
You can code it and try. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
agkshirsagar
NO I will not ask |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Vivek,
Quote: |
01 A PIC X(01) VALUE '4'.
01 B PIC X(01) VALUE X'04'.
.
.
.
IF A = B (WILL BE FALSE)
DO SOMETHING
ELSE
DO SOMETHING ELSE
END-IF |
You need to read the book for understanding BINARY in COBOL.
By this you dont mean binary but bitwise comparison.
You don't have to worrry because alphanumeric comparison will do the same. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello vivekbalokhra,
How did you define the 1-byte binary?
Quote: |
How can we define a working storage variable with value x'04' and compare the same, with the variable which is a 1 byte binary ??
|
The qualification posted
Quote: |
1. I HAVE ONE VARIABLE, 'A' WHOSE PIC IS X(01) AND VALU STORED IS 4, AND THATS IS DEFINED AS 1 BYTE BINARY.
2. I HAVE TO DEFINE A VARIABLE IN WORKING STORGE WHOSE VALUE IS X'04' AND TO COMPARE IT WITH 'A'. |
does not appear to be consistent. An X(01) is not a binary definition - it is an alphanumeric definition. You post the value is 4 - which "4" is it? There is a difference between x'04' and '4'. The '4' is an x'F4'.
You can define your 1-byte field and successfully compare against it. You need to specify the proper field/literal definitions. It's not like there is a rignt or wrong here, just the need to make sure that both sides are defined properly.
Please let us know if you'd like more info. |
|
Back to top |
|
|
|