sin() function problem

**Hello everybody,

I have some problems in programming the controller.

when i tried to printf() the result of sin() function the terminal dosen’t show nothing.

the code’s lines:

float result,angle;
float PI = 3.14;

angle=30.0;
result= sin (angle*PI/180);
printf(“the sine of angle %f is %f”,angle,result);

=============

if somebody knows how to reslove this problem it will be great.

thanks
Nir Haim
TEAM 1942.**

Placing “\r” at the end of your printf string will cause it to print.
Did you use: #include <stdio.h>

Finally, “%f” is not supported by printf on this compiler and printf will not take floats as arguments, so you have to play a trick to print it.

Standard Disclaimer: Floating point is not directly supported on the PIC, so it’s bulky and slow. Avoid it if you can.

Try this:

printf("the sine of angle %d is %d\r",(int) angle,(int) (result * 1000.0));

Note that “result” will be a number between 0 and 1 which will truncate to 0 or 1 when type cast to an integer. Multiplying by 1000 will display a number between 0 and 1000.

Also, I echo Mark’s disclaimer. Floating point arithmetic is extremely inefficient.

Mike