Hi,
I've been asked this in an interview - explain the internal format of 1234 in COMP, COMP-1, COMP-2, COMP-3? I'm not sure how to answer that. Can someone please explain and help.
And what will be the size of 1234 in all computational definitions?
How 1234 will be in COMP, COMP-1, COMP-2, COMP-3?
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: How 1234 will be in COMP, COMP-1, COMP-2, COMP-3?
Size for USAGE COMP depends on your PICture. If you have PIC 9(4) then it is two bytes, a half-word. What you would see, is the binary value which gives 1234, preceded by zeros if necessary. COMP-1/COMP-2 are floating-point. They are fixed size and cannot have a PICture. COMP-3 size again depends on the PICture. For PIC 9(4) it would be X'01234F'.
Easiest thing for you to do, is have a little program, define and REDEFINES (as PIC X(n)) each field that you want and then DISPLAY the REDEFINES field, look at the output in HEX. Otherwise refer to the manual, understand, memorize and probably never need to know for COMP-1 and COMP-2
Easiest thing for you to do, is have a little program, define and REDEFINES (as PIC X(n)) each field that you want and then DISPLAY the REDEFINES field, look at the output in HEX. Otherwise refer to the manual, understand, memorize and probably never need to know for COMP-1 and COMP-2
- Robert Sample
- Global Moderator
- Posts: 1895
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: How 1234 will be in COMP, COMP-1, COMP-2, COMP-3?
COMP variables are 2, 4, or 8 bytes long depending upon the PICTURE clause. COMP-1 variables are 4 bytes long. COMP-2 variables are 8 bytes long. COMP-3 variable length depends upon the specific PICTURE clause used but will generally be 1/2 the number of digits in the PICTURE clause (plus 1 if the number of digits is even).
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute