|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||||
|
|||||
|
Re: sin() function problem
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. Last edited by Mark McLeod : 22-01-2007 at 11:23. |
|
#3
|
||||
|
||||
|
Re: sin() function problem
Try this:
Code:
printf("the sine of angle %d is %d\r",(int) angle,(int) (result * 1000.0));
Also, I echo Mark's disclaimer. Floating point arithmetic is extremely inefficient. Mike |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Math.h sin syntax error | Sykan | Programming | 8 | 21-01-2007 09:26 |
| Arcade Function | gabrielse | Programming | 1 | 08-02-2006 00:49 |
| Limit_Mix() Function | EricWilliams | Programming | 2 | 27-07-2005 23:19 |
| Sin, Cos, Atan | the_undefined | Programming | 3 | 16-02-2005 02:32 |
| FreeLibrary() Function | Raven_Writer | Programming | 0 | 09-08-2003 15:39 |