Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Double to Packed decimal conversion in Mainframe 'C'

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests
View previous topic :: :: View next topic  
Author Message
sampaul4u

New User


Joined: 27 Mar 2010
Posts: 19
Location: folirida

PostPosted: Fri Sep 17, 2010 4:16 pm    Post subject: Double to Packed decimal conversion in Mainframe 'C'
Reply with quote

Hi,
Could anyone assist me to write a function in IBM "C" to convert Double value to Packed Decimal format?

Please advise me.

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

Bill O'Boyle

CICS Moderator


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

PostPosted: Fri Sep 17, 2010 4:30 pm    Post subject: Reply to: Double to Packed decimal conversion in Mainframe '
Reply with quote

What do you mean by "Double" value? Is this a doubleword (8-bytes)? Are the field contents binary? Are the field contents display-numeric?

What language is the program that needs to invoke this Function?

More information is needed....

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

New User


Joined: 27 Mar 2010
Posts: 19
Location: folirida

PostPosted: Fri Sep 17, 2010 4:45 pm    Post subject: Re: Reply to: Double to Packed decimal conversion in Mainfra
Reply with quote

I need this in C laguage. Double precision value (Ex 1000.11) needs to be converted to Packed decimal format (that is eaqualent to COBOL COMP-3)


Thanks.

Bill O'Boyle wrote:
What do you mean by "Double" value? Is this a doubleword (8-bytes)? Are the field contents binary? Are the field contents display-numeric?

What language is the program that needs to invoke this Function?

More information is needed....

Bill
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Fri Sep 17, 2010 4:53 pm    Post subject: Reply to: Double to Packed decimal conversion in Mainframe '
Reply with quote

why should we icon_question.gif icon_evil.gif
You did not even care to look at the manuals

start from
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/Shelves/CBCBS180 ( for example )
and search for DECIMAL and PACKED

after having read the manuals, if there is something not clear, somebody will be glad to help
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Fri Sep 17, 2010 4:57 pm    Post subject: Reply to: Double to Packed decimal conversion in Mainframe '
Reply with quote

Is this a management directive or is this your suggestion to management?

This can be done easily in a "Called" Assembler sub-program, using the "grande" instructions or in COBOL or PL/I for that matter.

Why must it be "C"?

Have you tried "Googling" this?

Bill
Back to top
View user's profile Send private message
Ian McIntosh

New User


Joined: 01 Sep 2011
Posts: 1
Location: Canada

PostPosted: Fri Sep 02, 2011 3:02 am    Post subject: Double to Packed Decimal Conversion in Mainframe C
Reply with quote

IBM mainframe C has a family of builtin packed decimal types, equivalent to COBOL COMP-3. The declaration syntax is
_Decimal (total_digits) varname;
or
_Decimal (total_digits, digits_after_decimal_point) varname;
and if you include <decimal.h> you can use decimal instead of _Decimal.

The operations on the decimal types are mostly the same as for other numeric types. Literals end with the suffix "D". Use "%D(total_digits, digits_after_decimal_point)" in printf and scanf.

To convert a double to decimal, just use an assignment statement or a cast.

double d = 123.456;
_Decimal (6,3) dd;
dd = d;
or
dd = (_Decimal(6,3)) d;

For more information, see
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/CBCLR170/3.3.4?SHELF=CBCBS180&DT=20070601155844

edited to fix a wrong URL
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 02, 2011 10:47 am    Post subject: Reply to: Double to Packed decimal conversion in Mainframe '
Reply with quote

Hello and welcome to the forum,

Thanks for posting this info.

Enjoy your time here and hopefully we will have things you find useful as well icon_smile.gif

d
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts FTP from Mainframe to Unix - with CRLF vasanthz All Other Mainframe Topics 5 Thu Mar 23, 2017 5:12 am
No new posts Want to pull the job log into a Mainf... Jishu Mukherjee Compuware & Other Tools 9 Tue Mar 21, 2017 4:48 pm
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us