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

Equivalent decimal value for Comp-4 Binary value 158


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

New User


Joined: 31 Jan 2006
Posts: 39

PostPosted: Fri Apr 13, 2012 5:37 pm
Reply with quote

Hi

Kindly let me know the equivalent decimal value for Comp-4 Binary value 158.

Thanks
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 13, 2012 5:46 pm
Reply with quote

Same as in COMP.
Back to top
View user's profile Send private message
Sumeendar

New User


Joined: 31 Jan 2006
Posts: 39

PostPosted: Fri Apr 13, 2012 5:53 pm
Reply with quote

Is decimal value 344 equivalent to COMP-4 binary value 158.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Apr 13, 2012 6:04 pm
Reply with quote

No, decimal 158 is equivalent to COMP-4 binary value 158 -- the form of the number will not change the value. Hexadecimal value x'0158' has the value of 344 in decimal -- the representation of the number will determine the hexadecimal characters used to identify the value, but the value won't change.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 13, 2012 6:11 pm
Reply with quote

These days there are even PCs with calculators. Either "scientifc" or "programming".

The way we did it was just to learn base 16 maths. As an aid there was the old green/yellow card.

You have one 256, five 16s and eight. Add 'em all up. If you practice it, it'll work when you don't have ready access to a calculator and won't interrupt the "flow" of dump-reading/disk/tape viewing etc.

Or you can ask on a forum and take the knocks.
Back to top
View user's profile Send private message
Sumeendar

New User


Joined: 31 Jan 2006
Posts: 39

PostPosted: Mon Apr 16, 2012 2:20 pm
Reply with quote

I have a binary value (pic 9(4) comp-4 type), with hex on gives 0135 .

I tried to convert this binary value to zoned decimal for display purpose using the below build function

BUILD=(1:51,2,BI,ZDF,LENGTH=4)

After the execution i got the zoned decimal value as 0309.

Please let me know if this is correct.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Apr 16, 2012 2:25 pm
Reply with quote

That would be one 256, three 16s and five.

Have you not even found the calculator?

At least you found DFSORT.

EDIT: There has to be something deeper here, doesn't there?

Code:
01  a-group.
    05  a-comp-4 comp-4 pic 9(4) value 309.

DISPLAY ">" a-group "<>" a-comp-4 "<"


Put it in a program. Compile, run. SET HEX ON for the output. You gave it 309, it gave you back 135 (from the hex display) and 309.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Apr 16, 2012 2:30 pm
Reply with quote

is it so difficult to find out Yourself... icon_eek.gif
if it is so a career change is strongly suggested

don' t You have an hex/dec calculator ?
all the windoze systems have one

or just try to remember Your basic maths and ...

Code:
1 * 256 ==> 256 +
3 *  16 ==>  48 +
5 *   1 ==>   5 =
--------------------
        ==> 309
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top