Need function to convert float/double/long to string using a specified format 
Author Message
 Need function to convert float/double/long to string using a specified format

Hi,
I am looking for C routines that can convert a float, double, or long
to a string using a conversion specification at a higher level then
sprintf. For example if the number is 1000000 and I want it to be
formatted as "1,000,000" the I would call the function as
function_name(double number, "###,###,###", char *string, int
stringsize); This is standard in many higher level languages, but I
have yet to find a library that can do this in C (besides libraries
that come with database packages, like informix).

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 27 May 2002 03:00:00 GMT  
 Need function to convert float/double/long to string using a specified format

Quote:

> I am looking for C routines that can convert a float, double, or long
> to a string using a conversion specification at a higher level then
> sprintf. For example if the number is 1000000 and I want it to be
> formatted as "1,000,000" the I would call the function as
> function_name(double number, "###,###,###", char *string, int
> stringsize);


In C that's not supported by the language itself. But have a look at the
SNIPPETS source code collection, where you will find some support for what
you want to do. There is a section called "Numerical <=> string conversion
functions" which looks very promising. You can get SNIPPETS at:
    http://www.snippets.org/

--
Stephan
initiator of the campaign against grumpiness in c.l.c
fight the bug, read the FAQ: http://www.eskimo.com/~scs/C-faq/top.htm



Tue, 28 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Convert double to D-float format

2. convert string to long double - problem

3. Convert a String to float/double

4. convert string to long, and long to string

5. epsilon for float, double long double

6. function to convert time from ascii to long format

7. Converting long double to double

8. formatting long strings using sprintf()

9. formatting long strings using sprintf() without including tabs or newlines

10. format string for long long

11. Using CDC TextOut function with doubles & floats

12. Need source to convert a string to float

 

 
Powered by phpBB® Forum Software