using floats with macosx

Discuss new features and future development.

using floats with macosx

Postby diegor » Sat Jan 14, 2012 8:32 pm

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!
diegor
 
Posts: 6
Joined: Wed Jun 22, 2011 12:38 pm

Re: using floats with macosx

Postby slembcke » Sat Jan 14, 2012 10:07 pm

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: using floats with macosx

Postby diegor » Sun Jan 15, 2012 9:02 pm

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!
diegor
 
Posts: 6
Joined: Wed Jun 22, 2011 12:38 pm

Re: using floats with macosx

Postby slembcke » Sun Jan 15, 2012 9:48 pm

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm


Return to Features/Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron