gcc int to float conversion problem

Jason Lutz jlutz7777@hotmail.com
Fri Oct 6 01:02:00 GMT 2006


I don't know if this is the right forum for asking questions, so I am sorry 
up front if it is not.  My question is in regards to a problem I am having 
converting from an int to float for the arm processor.

Here is my code:

int i_var1=1;
float f_var2=0.0;
char c_var3[10];
f_var2=(float)i_var1/310.00;
sprintf( c_var3, "%f", f_var2 );

I then later print c_var3 to a web page I am hosting from my ARM processor.  
The important thing to note is that when it is printed, it only gives me 
",,".  If I just print an integer, it works fine.  For example:

int i_var1=5;
char c_var3[10];
sprintf( c_var3, "%i", i_var1 );

Is there an error with the gcc compiler for ARM (arm-elf-gcc)?  Maybe I am 
doing something wrong and just cannot figure it out, but if I use this code 
on my x86 and do a printf, it works fine with the integer or float.  Any 
workaround would be much appreciated.

Thank you,
Jason Lutz




More information about the Gcc-help mailing list