RE: Multiple gpio asynchronous read

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, I need help!
The following program :
#include
#include
#include

int main(void)
{
float Counter = 0,SinOfCounter;
printf("\n");
while(1)
{
double tmp;
Counter += 0.001;
tmp = Counter;
while (tmp > M_PI) tmp -= 2*M_PI;
SinOfCounter = sinf(tmp);
printf("\rCounter = %+12.3f (sin(%+7.4f) = %+7.4f)",Counter,tmp,SinOfCounter);
if (fabs(SinOfCounter) > 1.0) printf("\n\r");
}
}

compiles fine : avr32-linux-gcc -lm testm.c
The output though is unexpected:
Counter = +29.059 (sin(-2.3569) = -1.3987)
Counter = +29.315 (sin(-2.1009) = -0.8627)
etc...
Why is this simple floating point program not giving the right answers?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which toolchain are you using?

There was a floating point issue which was solved with the latest release, gcc 4.2.2.atmel.1.0.8.

I also split this topic as it is clearly posted wrong.

Hans-Christian