What about just using sprintf into a string and then cout the string? HTH
Peter -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Charles Mills Sent: Tuesday, April 25, 2017 7:08 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Can XLC printf() take "%D(*,*)"? Hmmm. Thanks. Link certainly seems relevant. (Interesting -- the page that opens is some weird VM-z/OS hybrid: z/VM z/VM 6.2.0 IBM XL C/C++ for z/VM z/OS: XL C/C++ Programming Guide Coding: Advanced Topics Using decimal data types in C Programming examples.) But I find the same example in the z/OS XLC P/G PDF, so macht nichts. But I consistently get 'D(*,*' for output. Here is my exact format: "%*.*D(*,*)" and I am calling it with 20, 5, &decimal_number, precision, scale. (I started out with 20, 5 like in the example just to make my life easier.) Here's a rub. The code is C++ and fixed point decimal support is limited to C ... but ... at the Spring TDM I asked a guy from Toronto why the heck the fixed point decimal support is only C and not C++. He told me -- very interesting story but I am going to play it safe here and assume it is under NDA. But he did tell me that I could call printf() from C++ and format fixed point decimal with no issues as printf() is a C function, not C++. I had not added decimal.h to my code as there is no packed logic other than the printf() (data comes in from an external source). I added the #include but still no joy. I think I will write to the Toronto guy and ask him the same question I asked here. Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of David W Noon Sent: Tuesday, April 25, 2017 3:32 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Can XLC printf() take "%D(*,*)"? On Tue, 25 Apr 2017 15:11:09 -0700, Charles Mills (charl...@mcn.org) wrote about "Can XLC printf() take "%D(*,*)"?" (in <0c3301d2be10$d87ed2b0$897c7810$@mcn.org>): > I'd like to format fixed point decimal (packed, in other words) > numbers in a common subroutine that would be passed the precision and > scaling. Can > printf() and friends take '*' and then a passed integer for its (n,p) > values > - analogous to the way printf() width and precision may be specified? KC offers this: <https://www.ibm.com/support/knowledgecenter/SSB27U_6.2.0/com.ibm.zos.r12.cb cpx01/pex1.htm> This page contains the following: printf("pd02 = %*.*D(*,*)\n", 20, 5, digitsof(pd02), precisionof(pd02), pd02); This appears to do what you want, but you will need to specify the width and decimal places for the output field too. -- This message and any attachments are intended only for the use of the addressee and may contain information that is privileged and confidential. If the reader of the message is not the intended recipient or an authorized representative of the intended recipient, you are hereby notified that any dissemination of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail and delete the message and any attachments from your system. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN