Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to compare one byte binary

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: How to compare one byte binary
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: 685
Location: Earth

PostPosted: Thu Apr 05, 2007 3:07 pm    Post subject:
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    Post subject: Re: how to compare 1 byte binary
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Thu Apr 05, 2007 3:38 pm    Post subject:
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: 685
Location: Earth

PostPosted: Thu Apr 05, 2007 3:58 pm    Post subject:
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

Site Director


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

PostPosted: Fri Apr 06, 2007 12:19 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts resume binary ftp in z/os meykh2014 All Other Mainframe Topics 5 Sun Jan 22, 2017 10:01 am
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts COMPARE command sivatechdrive TSO/ISPF 7 Fri Sep 16, 2016 4:31 pm
No new posts Icetool or Joinkeys example to compar... ishant chauhan DFSORT/ICETOOL 21 Sat Aug 20, 2016 2:40 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us