IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to compare one byte binary


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vivekbalokhra
Warnings : 1

New User


Joined: 15 Jul 2005
Posts: 6

PostPosted: Thu Apr 05, 2007 2:53 pm
Reply with 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 ??
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Apr 05, 2007 3:07 pm
Reply with quote

Simple..
Code:
  01 VAR1 PIC X(01) VALUE X'04'.

Quote:

1 byte binary ??

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
Code:
  IF VAR1 = X'04'

I am not sure if I've answered your concern correctly.
Back to top
View user's profile Send private message
vivekbalokhra
Warnings : 1

New User


Joined: 15 Jul 2005
Posts: 6

PostPosted: Thu Apr 05, 2007 3:32 pm
Reply with quote

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
View user's profile Send private message
vkphani

New User


Joined: 29 Oct 2003
Posts: 29

PostPosted: Thu Apr 05, 2007 3:36 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Apr 05, 2007 3:38 pm
Reply with quote

agkshirsagar

NO I will not ask icon_biggrin.gif
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Apr 05, 2007 3:58 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Apr 06, 2007 12:19 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top