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? -- Regards, Dave [RLU #314465] *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* david.w.n...@googlemail.com (David W Noon) *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN