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

Integer to Floating conversion error

I get strange behaviour with integer conversion; in the following example T4Frozen never reaches the value 790 because it turn back to 700 when it step over 767. This happen both on the target and on Dscope.

 T4Frozen=700;
 while(TRUE){
   PeriodoEncoder=(float)T4Frozen;
   PeriodoEncoder/=2.5;
   T4Frozen++;
   if(T4Frozen>790){
     Dummy=700;
   }
 }
Thanks in advance for your answer

Parents
  • We use floats into main and 2 ISRs, and so I'm really worried about:

    Aside from the fact that any operation on a float ... involves calls to library functions which I would guess are not reentrant

    This is much more difficult to manage than data consistence. We can't disable interrupts (or at least one of them) so we are trying to use integers where it is possible, and could be hard work. Any other way could be dangerous.
    Thanks a lot

Reply
  • We use floats into main and 2 ISRs, and so I'm really worried about:

    Aside from the fact that any operation on a float ... involves calls to library functions which I would guess are not reentrant

    This is much more difficult to manage than data consistence. We can't disable interrupts (or at least one of them) so we are trying to use integers where it is possible, and could be hard work. Any other way could be dangerous.
    Thanks a lot

Children