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: 10211
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 Produce Mainframe Dash Board Reports ... sdcarlson53 All Other Mainframe Topics 2 Thu Jan 05, 2017 11:01 pm
This topic is locked: you cannot edit posts or make replies. Urgent Mainframe Requirments (2-10 yr... Shankar779 Mainframe Jobs 0 Sun Nov 27, 2016 1:48 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm
This topic is locked: you cannot edit posts or make replies. Mainframe Developer requirement in Ku... capricorn Mainframe Jobs 0 Sun Oct 23, 2016 3:49 pm


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