Re: Converting packed decimal to a char array

Jon Paris <[email protected]>
Newsgroups gmane.comp.lang.as400.c
Message-ID <[email protected]>
It would help to know why you are trying to do this (editing the number for example?).

Have you looked at the various editing and conversion capabilities available in the surfaced MI functions (https://publib.boulder.ibm.com/iseries/v5r1/ic2924/books/c0924180.pdf) as well as the C/C++ library extensions? (http://www-01.ibm.com/support/knowledgecenter/#!/ssw_ibm_i_72/rtref/rtrefmain.htm).

Everything you could need is there.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jan 9, 2015, at 4:00 AM, Jevgeni Astanovski <[email protected]> wrote:

> Hi all,
> 
> spend a lot of time and feeling like I run into a dead cycle with a
> problem, that looks trivial.
> 
> I have packed decimals in my C programs that I need to convert to a
> char array, representing the number (not zero terminated string).
> 
> For example:
> 
> decimal (15,9) A ;
> char szTemp[32], sField[16] ;
> 
> sprintf(szTemp, "%016D(15,9)", A) ;
> memcpy(sField, szTemp, 16) ;
> 
> What I want to achieve is get a function, that receives A and returns sField.
> Of course it must support any types of decimal - not only decimal
> (15,9) but others like decimal(11,7), decimal (15,0), decimal (5,0)
> and so on. And, of course, decimal can be positive or negative...
> 
> 
> Any ideas?
> 
> Jevgeni.
> -- 
> This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
> To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected]
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/c400-l
> or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/c400-l.
> 

-- 
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.