This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcc int to float conversion problem


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]