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

How is sign stored in a comp-3 field / COMP field


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Fri Apr 21, 2006 12:57 pm
Reply with quote

1. How is sign stored in a comp-3 field / COMP field?
2. Synchronised Clause - often asken?
3. Difference between -ve and + ve sqlcodes?
4. Explain difference between TEST and OPTIMIZE Compile directives - one of the Interview Questions.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 22, 2006 7:08 am
Reply with quote

Hi KS,

1) COMP-3 stores the sign inthe low order half byte of the field. Ex. -123 is strored as X'123D'; +123 as X'123C'; 123 as X'123F'.

COMP stores the sign in the hi order non-significant bits of the field. Ex. +1 is stored as B'00000001'. As you see the sign is zero; -1 is stored as
B'11111111', the sign is 1.

If you take the pos COMP +1 and "flip" each bit, you get B'11111110' then add B'1'. You get B'11111111' or X'FF'. That's how you change a pos COMP field to a neg field.

That's why you see a lot of move -1 to switches and such from IBM. It's really a way to set it to X'FF'.

2) SYNC aligns a COMP field on half or full word boundary.

3) +ve, good; -ve, bad.
4) OPT... the compiler makes your code more efficient. TEST - not sure.
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
Search our Forums:

Back to Top