Page 1 of 3

Low values and High values

PostPosted: Wed Feb 20, 2008 3:46 pm
by pcdoctor
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

Re: low values and high values

PostPosted: Wed Feb 20, 2008 4:09 pm
by CICS Guy
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'

Re: low values and high values

PostPosted: Thu Feb 21, 2008 11:44 am
by rawatdewan
low values 0000000 of hex and high values FFFFFFFF of hex

Re: low values and high values

PostPosted: Thu Feb 21, 2008 9:30 pm
by pcdoctor
Thanks alot guys..

Re: low values and high values

PostPosted: Thu Feb 21, 2008 9:32 pm
by pcdoctor
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????

Re: low values and high values

PostPosted: Thu Feb 21, 2008 9:42 pm
by CICS Guy
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'.....

Re: low values and high values

PostPosted: Thu Dec 15, 2011 4:00 pm
by Sivaji
Can you guys quote with an actual usage when we can use the low/high values and initialize?

Re: low values and high values

PostPosted: Thu Dec 15, 2011 4:04 pm
by BillyBoyo
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.

Re: low values and high values

PostPosted: Thu Dec 15, 2011 4:13 pm
by Sivaji
@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..

Re: low values and high values

PostPosted: Thu Dec 15, 2011 4:40 pm
by BillyBoyo
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.