Re: gcc int to float conversion problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Jason Lutz" <jlutz7777@xxxxxxxxxxx> writes:

> 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.

This looks like a problem with whatever C library you are using, not
with gcc itself.  gcc does not provide sprintf.

It is possible that there could be a compiler problem here related to
passing float to a varargs function, but I don't see how that could
wind up producing ",," no matter how much it messed up.

It is of course also possible that c_var3 is getting clobbered
somewhere before you print it.

Ian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux