Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Amb

New User

Joined: 12 Mar 2010
Posts: 64
Location: India

 Posted: Wed May 12, 2010 4:34 pm    Post subject: Need to convert Binary value to Decimal Hi Guys, I have a variable which contains a binary value. I need to convert it to a decimal value. Please let me know if we have an intrinsic function in COBOL to do this. If not can you please give me a small logic to do the same.

Bill O'Boyle

CICS Moderator

Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

Posted: Wed May 12, 2010 4:50 pm    Post subject: Reply to: Need to convert Binary value to Decimal

 Code: 03  WS-BINARY PIC S9(09) BINARY VALUE 1234. 03  WS-PACKED PIC S9(15) PACKED-DECIMAL. * MOVE WS-BINARY TO WS-PACKED.

Please spend more time reviewing basic stuff. This aggravates many members....

Bill
Kjeld

Active User

Joined: 15 Dec 2009
Posts: 365
Location: Denmark

 Posted: Thu May 13, 2010 2:37 am    Post subject: And no... MOVE is not an intrinsic function in Cobol Thanks Bill, for bothering.
Anuj Dhawan

Senior Member

Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

 Posted: Thu May 13, 2010 4:31 pm    Post subject: First, are you wanting to display the decimal equivalent of some Binary number or just the Decimal value of digits in Binary? Example: the binary for '1' is 0001, '2' is 0010, etc. This is VERY different from the Binary for 12345, for example? Either way, you convert from a number base by dividing by the number base, using the remainder as the digit position, from right to left in the result and looping until the quotient is zero. You do the inverse to go the other way. Another way would be to use a table with the decimal digits encoded as binary literals, but this only works on a digit basis and not a logical number base. And why COBOL functions looks like a choice to you?
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm Can EDCICONV convert EBCDIC to ASCII... natt.sut IBM Tools 3 Fri Nov 17, 2017 8:46 pm Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us