IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

About Comp-4, Comp-5, Comp-6


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shasikanthsingh

New User


Joined: 29 Oct 2003
Posts: 1

PostPosted: Wed Oct 29, 2003 7:51 pm
Reply with quote

hi,

if any one know are heard about comp-4,comp-5,comp-6 please post the reply this was asked in my interview.

and if any one heard about 76 and 78 level number give the information


with regards,

harini navathi
Back to top
View user's profile Send private message
mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 237
Location: USA

PostPosted: Wed Oct 29, 2003 10:42 pm
Reply with quote

The format of a COMP-4 item is two's-complement binary. COMP-4 values are stored in a machine-independent format. This format places the highest-order part of the value in the leftmost position and follows down to the low-order part in the rightmost position. The number of bytes a data item occupies depends on the number of "9"s in its PICTURE and on the presence of various compile-time options. This is summarized in the following table:


Code:
# of "9"s    Default    -D1    -Dm
  1-2            2           1       1
  3-4            2           2       2
  5-6            4           4       3
  7-9            4           4       4
 10-11           8           8       5
 12-14           8           8       6
 15-16           8           8       7
 17-18           8           8       8

The format of a COMP-5 data item is identical to a COMP-4 data item, except that the data is stored in a machine-dependent format. It is stored in an order that is natural to the host machine. For example, a PIC S9(4) COMP-5 data item is equivalent to a 16-bit binary word on the host machine, and a PIC S9(9) COMP-5 item is equivalent to a 32-bit word. Note that data stored in a COMP-5 field may not be transportable to other machines because different machines have different natural byte-orderings. On many machines (68000, most RISC), COMP-5 is identical to COMP-4. On others (80x86, VAX), it is the same with the bytes in the reverse order.

COMP-5 is primarily used to communicate with external programs that expect native data storage. A VALUE clause for a COMP-5 data item is stored in a machine-independent format and is adjusted when it is loaded into the data item. This ensures that the value is the same from machine to machine.

Level 01 and level 77 data items that are COMP-5 are automatically synchronized to an appropriate machine boundary, regardless of any compile-time settings. This allows you to pass these items safely to C subroutines without having to concern yourself with alignment.

The format of a COMP-6 item is identical to a COMP-3 item except that it is unsigned and no space is allocated for the sign. Thus there are two decimal digits per byte, and the actual size of the item is determined by dividing its PICTURE size by two and rounding up.


About Level 76 & 78, will get back to you on this.

Hope this helps

Regards

Mayuresh Tendulkar
Back to top
View user's profile Send private message
Dsingh29

Active User


Joined: 16 Dec 2008
Posts: 132
Location: IBM

PostPosted: Sat Nov 28, 2009 5:17 pm
Reply with quote

Hi,

I dont think there are any 76 and 78 levels in cobol.

I have only heard about 66, 77 and 88 levels.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Nov 28, 2009 6:32 pm
Reply with quote

looks like a guinness record icon_biggrin.gif
a reply to a post inactive for...

Code:

years 1           6 ( months difference / 12 )
years 2           6 ( years difference )
months           73
days           2221
hours         53322
minutes     3199355
seconds   191961300


here is the silly code
Code:

#!/opt/ooRexx/bin/rexx

numeric digits 64

daten = "20091128-12:47:00"
dateo = "20031029-18:12:00"

diff = d2s(daten) - d2s(dateo)

say "years 1 " right(( ( substr(daten,1,4)*12 + substr(daten,5,2) ) - ,
                 ( substr(dateo,1,4)*12 + substr(dateo,5,2) ) ) % 12,10) ,
                 "( months difference / 12 )"
say "years 2 " right(substr(daten,1,4) - substr(dateo,1,4),10) ,
                "( years difference )"
say "months  " right(( substr(daten,1,4)*12 + substr(daten,5,2) ) - ,
               ( substr(dateo,1,4)*12 + substr(dateo,5,2) ),10)
say "days    " right(diff % ( 60 * 60 * 24 ),10)
say "hours   " right(diff % ( 60 * 60 ),10)   
say "minutes " right(diff % ( 60 ),10)
say "seconds " right(diff,10)
exit

d2s:procedure
   parse arg dt
   parse var dt d "-" h ":" m ":" s
    return date("b",d,"s")*(24*60*60) + h * 60 * 60 + m * 60 + s
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top