David - Thanks. I will take your suggestions to heart and give them a try but the fact that the %D is printing as a D leads me to think that printf() is not recognizing the %D at all.
> I'm not sure what "limited to C" means in a C++ context. > After all, C is largely a subset of C++, albeit with a few wrinkles these days. Yep, that is why I was amazed and asked the gentleman at the TDM. I was amazed at the answer, which I do not feel at liberty to share. In any event it is true: there is no packed decimal support in C++; it is limited to C. Note the title of the P/G chapter: "Chapter 26. Using decimal data types in C" and the L/R section "Fixed point decimal types (C only)." > You should not be passing a pointer (&x); everything is passed by value. That may be a problem because I will then have to cast it as decimal and not sure I can do that in C++. I am wondering how I am going to cast it as I need to cast as D(s,p) and I don't know significance and precision at compile time, only at run time. I wonder how C passes a potentially 16-byte string by value. > How are you declaring the decimal variables? Currently I am not, for the above reason. Will give this all a try now. Thanks again, Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of David W Noon Sent: Wednesday, April 26, 2017 8:24 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Can XLC printf() take "%D(*,*)"? On Tue, 25 Apr 2017 16:07:38 -0700, Charles Mills (charl...@mcn.org) wrote about "Re: Can XLC printf() take "%D(*,*)"?" (in <0c5901d2be18$bc7c4900$3574db00$@mcn.org>): [snip] > 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.) Your parameter sequence is wrong. You need to pass: field width, by value decimal places, by value digitsof(x), by value precisionof(x), by value x, by value in that order. You should not be passing a pointer (&x); everything is passed by value. > 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'm not sure what "limited to C" means in a C++ context. After all, C is largely a subset of C++, albeit with a few wrinkles these days. I could understand that STL has no piping operator or I/O manipulators for packed decimal, but the manipulation of packed decimal values in general code should really be the same for C and C++. However, I did not write the IBM compiler(s), so I don't know how much code the C and C++ compilers share. > 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. How are you declaring the decimal variables? ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN