Low values and High values



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

Low values and High values

Postby pcdoctor » Wed Feb 20, 2008 3:46 pm

Hi,

I have a query about low values and high values in cobol..what exactly will be stored in a variable to which low or high values are moved..Normally we use it to initialize the variables but i wanna know wat content would be present in the variables aftr these values are moved..i had gone thro the manual and theoretically i could understand..i would really appreciate if somebody could give a practical example and explain..I would like to undstand this in a practical sense..


Thanks in Advance..
Regards
Nadeem
pcdoctor
 
Posts: 17
Joined: Mon Feb 18, 2008 10:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: low values and high values

Postby CICS Guy » Wed Feb 20, 2008 4:09 pm

All data is stored in bits, base 2 on/off bits.
Low valuse is where all bits of the byte are off. X'00' or '00000000'
High values is where all bits of the byte are on. X'FF' or '11111111'
The letter 'A' is X'C1' or '11000001'
CICS Guy
 
Posts: 246
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: low values and high values

Postby rawatdewan » Thu Feb 21, 2008 11:44 am

low values 0000000 of hex and high values FFFFFFFF of hex
rawatdewan
 
Posts: 14
Joined: Tue Jan 15, 2008 5:28 pm
Has thanked: 0 time
Been thanked: 0 time

Re: low values and high values

Postby pcdoctor » Thu Feb 21, 2008 9:30 pm

Thanks alot guys..
pcdoctor
 
Posts: 17
Joined: Mon Feb 18, 2008 10:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: low values and high values

Postby pcdoctor » Thu Feb 21, 2008 9:32 pm

Anothr small query..wat would be the advantage with initializing variables with low and high values when we can do the same using zero or spaces????
pcdoctor
 
Posts: 17
Joined: Mon Feb 18, 2008 10:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: low values and high values

Postby CICS Guy » Thu Feb 21, 2008 9:42 pm

pcdoctor wrote:Anothr small query..wat would be the advantage with initializing variables with low and high values when we can do the same using zero or spaces????
On the mainframe, zero is actually X'F0' or '11110000' and spaces are X'40' or '01000000'.....
CICS Guy
 
Posts: 246
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: low values and high values

Postby Sivaji » Thu Dec 15, 2011 4:00 pm

Can you guys quote with an actual usage when we can use the low/high values and initialize?
Sivaji
 
Posts: 8
Joined: Thu Dec 15, 2011 3:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: low values and high values

Postby BillyBoyo » Thu Dec 15, 2011 4:04 pm

Sivaji wrote:Can you guys quote with an actual usage when we can use the low/high values and initialize?


When you have a new question, please start a new topic, not continue an old topic.

You can use low-values or high-values with INITIALIZE whenever that you want those values in your table as a starting point.

If you can be more specific about what you want to know, you can expect a more specific answer.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: low values and high values

Postby Sivaji » Thu Dec 15, 2011 4:13 pm

@BillyBoyo: Sorry i am new member to this forum.. going forward will start a new topic..
Above discussion clearly shows what is the exact diff bw the low/high and zero and spaces..
just want to know the exact scenario(usage) or when i can go for a low/high value to a field or when i can go for a initialize a variable using zeroes and spaces..
Sivaji
 
Posts: 8
Joined: Thu Dec 15, 2011 3:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: low values and high values

Postby BillyBoyo » Thu Dec 15, 2011 4:40 pm

The answer is, whenever you need a low-value, you use it. Whenever you need a high-value, you use it. Etc.

The advantage of a low-value is that, in data that is sequenced/keyed, there is nothing before it. The advantage of a high-value is that there is nothing after it.

Particular uses of these facts are many, perhaps infinite :-)

A couple of examples.

If you want to access a VSAM KSDS dataset with a "partial" key, you give it the left-most/high-order part of the key that you know and set the rest of the key to low-values. You know then that you will get the reference for the first data that matches the high-order part of the key. If you had set it to spaces, you might have a problem if the first unknown part of the key contains non-character data (a packed or binary number for instance). You won't often come across that in keys, but I always set to low-values so that I don't have to wonder about whether spaces will work in this particular instance, or that the code will still work if the key definition changes, or if the code is copied to another program in which it then wouldn't work etc.

If there is a table that you want to use SEARCH on, it can be useful to initialise the tabel to high-values so that you will know when you have reached the end of the data in the table. I'd use high-values so that if someone changes to a SEARCH ALL the initialise does not need to change even if the person making the change does not make the table variable-length with OCCURS DEPENDING ON.

In any sequence checking, you can use low-values to show that nothing has yet been put in a saved key and high-values to indicate that there is no more data for the set that you are working with. The saved keys can "double-up" as FIRST-TIME and END-OF-FILE indicators, for instance.

If you have a table which you are storing data in, but part of that table can validly contain space, if you have initilised to high-values you will know when you see space there that it is data, not just the initital value.

The important thing to bear in mind is that low-values (x'00') is the lowest byte value you can get and high-values (x'FF') is the highest. These values can not be entered directly from a keyboard. You can use them in any situation where there properties are useful to you.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post