-
Convert double to *chart
I want convert double to char * string for insert in a .ini file
Code:
char mystring[50];
double mydouble;
sprintf(mystring, "%f", mydouble);
It runs ok, but when I have a very small double (for example
0.000000000000000000000000001)
It convert to 0.00000000 (=0) and not to 1.0e-20
Do you know how solve it?
Thanks
_______________________
Hip Hop Directo
Foros de musica
-
try to specify higher precision, say "%30.28f" which means 30 digits, 28 of which are for the fraction.
Last edited by Danny; 10-26-2005 at 09:53 AM.
Danny Kalev
-
Thanks it is better but, I would like it puts something as 1.3e-20, is this posible?
Thankss
-
yes, use the %e or %E format flags instead of %f.
Danny Kalev
-
This is the solucion "%e" in cientific mode
Thanks
-
btw, you want to initialize your buffer before using it:
char mystring[50] = {0};
...
Danny Kalev
Similar Threads
-
By WackoWolf in forum C++
Replies: 4
Last Post: 10-17-2005, 04:22 PM
-
Replies: 3
Last Post: 10-02-2005, 11:57 PM
-
Replies: 1
Last Post: 09-26-2005, 05:09 PM
-
Replies: 0
Last Post: 11-15-2001, 10:26 AM
-
By George Gilbert in forum vb.announcements
Replies: 0
Last Post: 08-19-2001, 11:34 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|