Re: math.h and floats.
Re: math.h and floats.
- Subject: Re: math.h and floats.
- From: "John C. Randolph" <email@hidden>
- Date: Mon, 24 Jun 2002 14:37:57 -0700
In Mac OS X, there are no sinf(), powf(), etc. functions. Just
use the double-precision versions, and pass them floats. The
compiler will do the right thing.
-jcr
On Monday, June 24, 2002, at 02: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.
John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
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.