Re: math.h and floats.
Re: math.h and floats.
- Subject: Re: math.h and floats.
- From: Vince DeMarco <email@hidden>
- Date: Tue, 25 Jun 2002 00:32:58 -0700
On Monday, June 24, 2002, at 02:23 PM, email@hidden wrote:
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..
No you don't the math functions are part of the system library.
The warnings I think are because you are passing ints (constant ints)
in the form of "2"..
Try 2.0 for the constants..
The man page is wrong there is only pow (which takes 2 doubles) and
sqrt which takes a double
powf and sqrtf are not there.
Please file a bug and ask that either the functions be added or the man
page updated.
vince
-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.
_______________________________________________
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.