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

Double to Packed decimal conversion in Mainframe 'C'


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Sep 17, 2010 4:30 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Sep 17, 2010 4:53 pm
Reply with quote

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

start from
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Sep 17, 2010 4:57 pm
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
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
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

Moderator Emeritus


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

PostPosted: Fri Sep 02, 2011 10:47 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Mainframe openings in Techmahnidra fo... Mainframe Jobs 0
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
Search our Forums:

Back to Top