×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ISCobol Data Type Definitions

ISCobol Data Type Definitions

ISCobol Data Type Definitions

(OP)
Could you point to or provide documentation that would show the appropriate way to code for COMP-1 and COMP-2 fields in Working Storage.

I read some documentation that the Picture clause is not allowed and that USAGE IS must be used. However, that does not compile cleanly in the ISCobol environment.

What I would hope to see is a list of data types and the definition for them. One would be non signed and the other would be signed.

Example of what I am looking to code correctly is shown below as the starter so you can see what I am trying to code.
For example, I would like to insert the value of 12.89 into C1-2 and 23.45 in C1-2S.
Of course, they do not have the decimal shown but if I code such as 99v999999999 it says out of range and the USAGE clause does not work

03 C1-1 PIC 9 COMP-1.
03 C1-1S PIC S9 COMP-1.
03 C1-2 PIC 9(18) COMP-1.
03 C1-2S PIC S9(18) COMP-1.

03 C2-1 PIC 99v99 COMP-2.
03 C2-1S PIC S99v99 COMP-2.

RE: ISCobol Data Type Definitions

I am a bit rusty on Cobol, but COMP-1 and COMP-2 are both floating point (short and long respectively) so the picture clause is irrelevant.

Have you tried:

03 C2-1 USAGE IS COMP-2.

I would be wary of using either of them as they are both approximations and may not always return the exact value you set them to. ( I am sire there are discussions of this on the internet of you want to see why.)

The purpose of them is to be able to hold very small (as in 0.000000000001) and very large (1000000000000000.0) numbers.

RE: ISCobol Data Type Definitions

(OP)
Thank you for sharing your knowledge.

I understand what you are saying about the precision. So, I will think about the concept of not even testing COMP-1 fields because a hard coded value to check against what the value the machine stores may not be exact and would, therefore, fail the compare.

HOWEVER.......in the meantime.....
I tried the USAGE IS COMP-1 on the C1-2 and C1-2S fields.
03 C1-2 USAGE IS COMP-1.
03 C1-2S USAGE IS COMP-1.


The compiler came back with this message:
Compiling programs for pgmtest.bat ...--S: #28 Missing picture clause C1-2; file = src\mypgm.cbl, line = 27, col 8
--S: #51 Missing FD for file: FCOMP; file = src\mypgm.cbl, line = 4, col 11
--S: #31 Expected/found token mismatch: PROCEDURE/03; file = src\mypgm.cbl, line = 28, col 4
Compiling result
Severe error(s) - 3
X --> src\mypgm.cbl: compilation failed


PLEASE NOTE THAT THERE IS NO COMPILE ERROR IF I COMPILE AS SHOWN IN THE ORIGINAL CODE IN MY ORIGINAL POST.
So, the missing FD error is a result of changing to C1-2 USAGE IS COMP-1 and C1-2S USAGE IS COMP-1 are what caused that error.

The COMP-2 fields seem to work as they are coded.
I think the issues is that ISCobol compiling does not recognize the USAGE IS COMP-1 phrase for a given field but I doubt it is a compiler setting as much as ISCobol just does not recognize USAGE.

RE: ISCobol Data Type Definitions

Further searches have not helped a great deal, although I did find this:

"COMP-1 refers to short floating-point format and COMP-2 refers to long floating-point format, which occupy 4 and 8 bytes of storage, respectively. The leftmost bit contains the sign and the next 7 bits contain the exponent; the remaining 3 or 7 bytes contain the mantissa."

The above is hardware specific.

Most sites I visited pretty much dodged the issue, although I did find one site with an example using "PIC(03) USAGE COMP-1", but this doesn't really make sense to me.

Good luck!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close