using floats with macosx

Discuss new features and future development.
Post Reply
diegor
Posts: 6
Joined: Wed Jun 22, 2011 12:38 pm
Contact:

using floats with macosx

Post by diegor »

I want to use the same precision (float) in both my ios and macosx builds of my code. The problem is that the macros in chipmunk_types.h read:

#if defined(__LP64__) && __LP64__
#define CP_USE_DOUBLES 1
#else
#define CP_USE_DOUBLES 0
#endif

Should the code be changed so those lines are ignored if CP_USE_DOUBLES have been already defined?

Thanks!
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: using floats with macosx

Post by slembcke »

It doesn't look like this? What version are you using?

Code: Select all

#ifdef CP_USE_CGPOINTS
	#if TARGET_OS_IPHONE
		#import <CoreGraphics/CGGeometry.h>
	#elif TARGET_OS_MAC
		#import <ApplicationServices/ApplicationServices.h>
	#endif
	
	#if defined(__LP64__) && __LP64__
		#define CP_USE_DOUBLES 1
	#else
		#define CP_USE_DOUBLES 0
	#endif
#endif
I thought I changed it to look like that a long time ago.

So it's a little wonky, but you have to set both CP_USE_CGPOINTS to be 0 and CP_USE_DOUBLES to be 0.

Also, why care which floating point precision? Using the same precision won't make the floating point math be the same between different CPUs or compilers. The only thing it does marginally help with is if you are accessing the memory directly like doing binary serialization or vertex arrays for GL or something.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
diegor
Posts: 6
Joined: Wed Jun 22, 2011 12:38 pm
Contact:

Re: using floats with macosx

Post by diegor »

The problem is that in my case I want to use floats and also CGPoints, that's why I was suggesting the change above, which should be harmless to existing code.

Thanks again for your help!
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: using floats with macosx

Post by slembcke »

CGFloats (and therefore CGPoints) are defined differently depending on if you are no a 32 or 64 bit system. That's why I have the 64bit check in the typedef.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests