This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Math library

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

Parents
  • 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.

Reply
  • 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.

Children