This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Float variable processing

In one of my project I am using ARM cortex m3. Here I am trying to print a float variable value into a string variable
ex. sprintf(sVar, "%f", 22.23);
the value returned in sVar is never correct.
But if I declare a float global variable, not even use this variable it starts printing value correctly into the sVar variable.
Can anyone explain what might be going wrong here?
THanks

Parents
  • Note that a float is 32 bit large. So when you have an immediate float value as parameter, the compiler will most probably implement identical code as if it pushed a 32-bit integer. Nothing for the linker to see, to understand that floating point support is needed.

    This is similar to the old Borland Turbo C days where "everyone" wondered why printf() wasn't able to print floating point numbers.

Reply
  • Note that a float is 32 bit large. So when you have an immediate float value as parameter, the compiler will most probably implement identical code as if it pushed a 32-bit integer. Nothing for the linker to see, to understand that floating point support is needed.

    This is similar to the old Borland Turbo C days where "everyone" wondered why printf() wasn't able to print floating point numbers.

Children
No data