Re: math.h and floats.
Re: math.h and floats.
- Subject: Re: math.h and floats.
- From: email@hidden
- Date: Mon, 24 Jun 2002 16:23:12 -0500
Well the undefined symbols are because (read man 3 math) you did not
tell the linker to include the math
library.. you need a "-lm" argument to the linker..
The warnings I think are because you are passing ints (constant ints) in
the form of "2"..
Try 2.0 for the constants..
-SJM
On Monday, June 24, 2002, at 04:05 PM, Matthew Cox wrote:
under exp in the man pages, the following function is defined:
float
powf(float x, float, y");
Under sqrt in the man pages, the following function is defined:
float
sqrtf(float x);
After using #include "math.h" in the header file, I the following line
of code produces an error and some warnings:
dInit = sqrtf(powf([self deltaX], 2) + powf([self deltaY], 2)); //The
pythagorean theorem
Here is the error...
/usr/bin/ld: Undefined symbols:
_powf
_sqrtf
Here are the warnings...
VectorPath.m:97: warning: type mismatch in implicit declaration for
built-in function `sqrtf'
VectorPath.m:97: warning: implicit declaration of function `powf'
Why does the above statement fail? I'm assuming that math.h may not
define these symbols, even though they are in the man pages (have a look
under "man sqrt" and "man exp".) Both of these man pages tell the user
to include <math.h>
The f at the end of the functions are to differentiate them from
functions using doubles. Since the results are going into NSPoints,
using doubles wastes resources.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.