1 Reply Latest reply on May 18, 2017 2:43 AM by user_1377889

    Problems assigning a negative float value

    user_385543602

      Hi,

         

      I am having trouble assigning a negative value to a float variable.  The first problem happens here assigning one variable value to another:

         

      testAvg = atan2(yAccum / avgCount,xAccum / avgCount) * 180.0f / M_PI;
              directAvg = testAvg;

         

      testAvg = -112.5

         

      directAvg value is -82.5

         

      Secondly, directly trying to assign a value:

         

      directAvg = -112.5f;

         

      directAvg value is 0

         

      I am missing something very basic here.  Thank you for your help.

         

      Regards,

         

      Tom

        • 1. Re: Problems assigning a negative float value
          user_1377889

          Well, Tom, I think you can imagine that assigning negative values to a float variable does certainly work. So the bug lures on a different place, not the assignment.

             

          How do you get knowledge of the actual value? Debugger output?? sprintf()???

             

          When sprintf() make sure Buffer large enough, heap size set to 0x0200 and newlib nano float formatting enabled.

             

          Can you verify (by setting an address breakpoint) that no write access happens unwanted to your variables?

             

           

             

          Bob