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
  • I understand that this might be happening in the background but I fail to understand why a local float defined does not solve this. It requires a global definition to resolve the issue.
    I have seen examples from Keil website for printf and that doesn't do anything different from what I've done.
    Can you suggest libraries that I should include manually to remove this such dependency because I tried few but that didn't solve the problem.
    Appreciate your help.

Reply
  • I understand that this might be happening in the background but I fail to understand why a local float defined does not solve this. It requires a global definition to resolve the issue.
    I have seen examples from Keil website for printf and that doesn't do anything different from what I've done.
    Can you suggest libraries that I should include manually to remove this such dependency because I tried few but that didn't solve the problem.
    Appreciate your help.

Children