I have been running through the basics math.h examples in c.
All makes perfect sense. When compiling though... it complains if put x instead of 2.25 in each of the functions. - while in the generated object file.
double x = 2.25;
double less = 0.0;
double more = 0.0;
double root = 0.0;
double angle = 45.0;
double pi = 3.1419265;
double sine = 0.0;
double cosine = 0.0;
printf("\nExamples in maths.h - x = 2.25\n");
less = floor(2.25);
printf("\nless = floor(x) is %.2f",less);
more = ceil(2.25);
printf("\nmore = ceil(x) is %.2f",more);
root = sqrt(2.25);
printf("\nroot = sqrt(x) is %.2f",root);
// sine = sin(pi*angle/180.0);
printf("\nsin(%.6f*%.2f/180.0) is sin(%.3f) = %.3f\n",pi, angle, sine);
[jryan@freedom lessons]$ gcc 2.20_mathExamples.c -o 2.20_mathExamples
/home/jryan/tmp/ccvACeHe.o: In function `main':
2.20_mathExamples.c.text+0xb2): undefined reference to `floor'
collect2: ld returned 1 exit status
So take the error about floor for example... I had the other functions remmed out at the time of the above error - they all error with the same message. So, if I hardcode 2.25 instead of x in floor like in the code above. eg floor(2.25) instead of floor(x), it works! Hmm, what I am I doing wrong here? Similarly it does not recognise sign even though I did include math.h.