We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi.. I need to use the cos and sin functions. what are the libraries I need to add ? is it only <math.h> ? if yes, i tried that and i got error message:
/cygdrive/h/Ex3/FFT/FFT.c(45): error: undefined reference to 'cos'
Thankx
The compiler will convert (22./7.) into 3.1428...
If you want to use PI somewhere (named M_PI in the standard library) then it is best to define it as M_PI 3.14159265358979323846 (use whatever precision you need, and the target supports).
It is only if you play with fixed-point arithmetic that it may be meaningful to play with the rational format. In that case you can decide if you want to define PI as a fixed-point value, or if you want to separate the multiplication and the division, possibly gaining you extra precision if you manually keep track of overflow and number of digits in intermediate results.
Actually i cant find the M_PI .. where is it ? in which library? is it in <math.h> ?? Note: i am using GNU compiler version 4.1.1
The nice little tool "grep" will tell you which file it is in. If grep can't find the symbol in any of your existing include files, then it just isn't there. Embedded compilers doesn't have all standard symbols defined...
i forgot to ask,, the angle of a cos or sin function is in radians or degrees.??
There are a huge number of functions available in the standard library. Hence, the only reasonable way you can make use of them is by making it a habit to check the manual. It will - of course - describe the parameters for the available functions.