× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Well your function needs to know the length and decimal places. So if you know those and can pass them to the function then just build the format string before using it in sprintf.

On 1/9/2015 10:00 AM, Jevgeni Astanovski 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.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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

This mailing list archive is Copyright 1997-2024 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.