View previous topic :: View next topic
|
Author |
Message |
sampaul4u
New User
Joined: 27 Mar 2010 Posts: 19 Location: folirida
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
sampaul4u
New User
Joined: 27 Mar 2010 Posts: 19 Location: folirida
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10889 Location: italy
|
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Ian McIntosh
New User
Joined: 01 Sep 2011 Posts: 1 Location: Canada
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
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
d |
|
Back to top |
|
|
|