Re: Overriding libSystem's math functions
Re: Overriding libSystem's math functions
- Subject: Re: Overriding libSystem's math functions
- From: Robert Purves <email@hidden>
- Date: Tue, 12 Dec 2006 23:29:24 +1300
Mike Blaguszewski wrote:
Greg Guerin wrote:
What do you intend to achieve by doing this? At what cost?
The application is a multiplayer simulation game, which I'm porting
to the Mac. The simulation needs to stay basically in sync (no
cumulative errors) over the course of the game. It already works fine
PC<->PC, since the binaries are identical, but PC<->Mac or even PPC<-
Intel is harder.
The game is mostly graphics-bound, so taking a hit in FP performance
is probably okay. Since this is a port of an existing app, I'm trying
to do the easiest reasonable thing that will work.
You could define macros for all the standard functions that call your
custom functions:
#define sin(x) foosin(x)
#define cos(x) foocos(x)
If you put those in your own local "foomath.h" header, then your code
#includes that file rather than <math.h>. Your source can still be
written as if it used the standard functions sin(), cos(), etc.
I think this is the probably the way to I'm going to have to go, as
the MS Visual C++ linker is less forgiving. Though even then it seems
like higher-level optimizations could cause differences between gcc
and MSVC, despite forcing strict IEEE math.
If your computations can be represented
final_val = initial_val + true_change + platform_dependent_error
it seems that you are trying to get different
platform_dependent_errors to match, by daring and difficult means.
Could you instead try to make platform_dependent_error small relative
to true_change? This is a well-travelled route in numerical
computation; in favourable circumstances it might involve only a
change of type, for the errant variables, from float to double.
Of course you would then need a PC version 2 of your game to match
the higher accuracy of the Mac version.
Robert P.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden