math.h and floats.
math.h and floats.
- Subject: math.h and floats.
- From: Matthew Cox <email@hidden>
- Date: Mon, 24 Jun 2002 17:05:58 -0400
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.