What I'm trying to accomplish is convert a void ptr (that's actually a
packed decimal) to a character representation of the pointed to packed
decimal value.

The natural way for me would be to cast the void ptr to a packed decimal and
then sprintf the decimal variable. But to do that I need to declare a
decimal variable that can hold any valid decimal values and the compiler
demands that the digits and precision are known at compile time.
Declaring one that holds the maximum values (that is, DEC_DIG and
DEC_PRECISION when using the C++ bcd.h file) and casting the void ptr into
that does not give the right result:

Using static_cast to cast say a dec(7,0) into dec(31, 31) results in garbage
(1 seems to become 0.00000000000...1) when I sprintf it.
Using cpynv to do the same thing crashes with MCH1210 (Receiver value too
small to hold result.).

This doesn't really make sense to me as a dec(7,0) should fit nicely into a
dec(31,31)?

Using cpynv to convert directly to a zoned decimal works, but I'd really
like to get the same visual result as sprintf-ing a packed decimal, that is
no leading zeroes, a decimal point... that kind of look.

Any suggestions would be most welcome.

Thanks,
Erik

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.