View previous topic :: View next topic
|
Author |
Message |
jeelagahema
New User
Joined: 12 Jun 2005 Posts: 12 Location: bangalore
|
|
|
|
why we will use comp-3 declaration? |
|
Back to top |
|
|
jsk
New User
Joined: 20 Feb 2006 Posts: 12
|
|
|
|
Hi Jeelagahema,
COMP-3 enables the computer to store two digits in each storage position, except for the rightmost position, which holds the sign. Suppose if you move 1234567 into a field defined 9(7). In DISPLAY mode, which is default, this field will use 7 storage positions.
If you define the field with PIC 9(7) COMP-3, it will however use only four positions
12 34 56 7+
We can save a significant amount of storage by using the USAGE-COMP-3
Please correct me if I am wrong |
|
Back to top |
|
|
raghunathns
Active User
Joined: 08 Dec 2005 Posts: 127 Location: rochester
|
|
|
|
you have to check the file status after each read
end of file.. do not process.. terminate program. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
jeelagahema,
Quote: |
why we will use comp-3 declaration? |
Just a subscript to what jsk posted. Along with the space savings that is present with COMP-3, it is also easier to read on a program dump than COMP or display, and it is more efficient for the processor than display. If you look at the object code produced by a arithmetic operation, you will fine that the complier converts display fields to COMP-3, does the operation and then converts back to display back to display. The hardware is designed to do the arithmetic operations with COMP-3 or COMP (binary), but not display fields.
Dave |
|
Back to top |
|
|
hncs
New User
Joined: 01 Mar 2006 Posts: 11
|
|
|
|
IF WE USE COMP-3 THEN THE EFFICIENCY IS MORE. AND MORE OVER IT WILL TAKE VERY LESS MEMORY COMPARED WITH DISPLAY.
COMP-3 IS NOTHING BUT PACKED DECIMAL VALUE.
SUPPOSE IF THE FIELD SIZE IS S9(N)
IF N IS EVEN THEN IT WILL TAKE (N+2)/2 BYTES.
IF N IS ODD THEN IT WILL TAKE (N+1)/2 BYTES.
FOR EACH DIGIT IT WILL TAKE HALF BYTE AND HALF BYTE FOR SIGN. |
|
Back to top |
|
|
|