GP32 conversion problem.


washo

Washo 4 evr
Joined
Oct 3, 2003
Messages
1,126
Age
39
Location
France (Marseille)
Website
Visit site
Maybe this is a stupid question but Im making a calculator and I need to print on th ecreen a double as a result...
How can I convert a double t a char[x]?
thx :)
see you ;)
 
That sprintf line looks strange. I'd use
Code:
double value;
char text [30];
sprintf (text, "%f", value);
I seem to remember some people saying that the sdk crashed when doing this sort of thing. It may have been their mistake (like not having a big enough buffer to put the text into), I'd be interested to know if it works for you.
 
Hi
I really need help : I must convert a double to a string to make GpTextOut able to run but sprintf is not working at all...
Which founction must I use?
PLZ tell me!
see you ;)
 
The SDK does NOT handle floats well at all. I believe adding a -fno-short-double (or possibly -fshort-double?) flag to your gp32.mk compiler line will fix it. Else use ftoa as generalnmx said (but Robster corrected).
 
sprintf() & floats are sometimes not working if the used libc is not ported correctly. As far as I remember sprintf with floats use malloc() internally and that might cause problems. The other working alternative is to use SDK's equivalent.. I think it was something gm_sprintf() or so :blink:
 
Back
Top