Re: Math.h functions with CGFloat

2010-08-10 Thread Quincey Morris
On Aug 10, 2010, at 14:00, Michael Ash wrote: > All operators with floating-point arguments must be performed with > double precision. However, the C spec operates according to the > "as-if" rule. The compiler is free to generate ANY code it wishes so > long as the result is the same "as if" it we

Re: Math.h functions with CGFloat

2010-08-10 Thread Rick Mann
Thanks. When I did the in-Xcode file search, it didn't turn up, so I was curious. On Aug 10, 2010, at 14:15:03, Nick Zitzmann wrote: > > On Aug 10, 2010, at 3:06 PM, Rick Mann wrote: > >> Is available on iOS? (I have code shared among platforms.) > > Yes: > > % find /Developer/Platforms/iPh

Re: Math.h functions with CGFloat

2010-08-10 Thread Nick Zitzmann
On Aug 10, 2010, at 3:06 PM, Rick Mann wrote: > Is available on iOS? (I have code shared among platforms.) Yes: % find /Developer/Platforms/iPhoneOS.platform -name 'tgmath.h' [...] /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/clang/1.5/include/tgmath.h /Developer/Platforms/iPhoneOS

Re: Math.h functions with CGFloat

2010-08-10 Thread Greg Parker
On Aug 10, 2010, at 2:06 PM, Rick Mann wrote: > On Aug 10, 2010, at 08:35:43, Kyle Sluder wrote: >> The correct thing to do is leave the warning enabled and #include . > > Is available on iOS? (I have code shared among platforms.) Yes; it's part of C99. -- Greg Parker gpar...@apple.com

Re: Math.h functions with CGFloat

2010-08-10 Thread Rick Mann
On Aug 10, 2010, at 08:35:43, Kyle Sluder wrote: > The correct thing to do is leave the warning enabled and #include . Is available on iOS? (I have code shared among platforms.) -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Plea

Re: Math.h functions with CGFloat

2010-08-10 Thread Michael Ash
On Tue, Aug 10, 2010 at 1:44 PM, Quincey Morris wrote: > Excuse me for jumping into this discussion with half a brain, but isn't there > another consideration? > > I was under the impression that C does not have symmetric support for > 'double' and 'float'. Specifically, I thought that any (a) e

Re: Math.h functions with CGFloat

2010-08-10 Thread Greg Parker
On Aug 10, 2010, at 10:44 AM, Quincey Morris wrote: > Also, I remember we had a discussion on this list a few months ago concerning > a warning flag that might have been 'Wshorten-64-to-32' or might have been > something vaguely similar, where someone from Apple jumped in to say that > using the

Re: Math.h functions with CGFloat

2010-08-10 Thread Quincey Morris
Excuse me for jumping into this discussion with half a brain, but isn't there another consideration? I was under the impression that C does not have symmetric support for 'double' and 'float'. Specifically, I thought that any (a) expression involving floating point numbers promoted everything t

Re: Math.h functions with CGFloat

2010-08-10 Thread Sean McBride
On Tue, 10 Aug 2010 16:50:17 +0100, Alastair Houghton said: > seems like a good solution. Indeed. I wish I knew about that before. :) A pity that Cocoa.h includes math.h and not tgmath.h. -- Sean McBride, B. Eng s...

Re: Math.h functions with CGFloat

2010-08-10 Thread Alastair Houghton
On 10 Aug 2010, at 16:28, Graham Cox wrote: > If your code is working with CGFloat, then the warning isn't very helpful, > because by using CGFloat you've elected to use 32-bit precision. Only on 32-bit. On the 64-bit runtime, CGFloat is a double, not a float, and therein lies the problem. If

Re: Math.h functions with CGFloat

2010-08-10 Thread Kyle Sluder
On Tue, Aug 10, 2010 at 8:28 AM, Graham Cox wrote: > If your code is working with CGFloat, then the warning isn't very helpful, > because by using CGFloat you've elected to use 32-bit precision. If you want > 'double', use 'double'. The warning could be useful on 64-bit compiles to > indicate t

Re: Math.h functions with CGFloat

2010-08-10 Thread Graham Cox
On 11/08/2010, at 1:08 AM, steven Hooley wrote: > But then e.g. when building 32-bit i still have to cast the return > value or i get the warning:- > > 'implicit conversion shortens 64-bit value into a 32-bit value' > > It seems that this warning is my fault because i have added the flag > -Wsh

Re: Math.h functions with CGFloat

2010-08-10 Thread steven Hooley
But then e.g. when building 32-bit i still have to cast the return value or i get the warning:- 'implicit conversion shortens 64-bit value into a 32-bit value' It seems that this warning is my fault because i have added the flag -Wshorten-64-to-32 which isn't enabled by default so maybe it should

Re: Math.h functions with CGFloat

2010-08-10 Thread Graham Cox
On 11/08/2010, at 12:12 AM, steven Hooley wrote: > Because CGFloat is typedef'd to float on 32bit and double on 64bit i > have to swap between, eg, atan and atanf depending on my build > settings. I have a framework which is intended to support 32bit and > 64bit. Just use atan(). 32-bit floats

Re: Math.h functions with CGFloat

2010-08-10 Thread James Montgomerie
You should, I believe, be able to include ('type generic math' - a C99 addition) instead, and then just 'use' the non-suffixed versions of the functions. Hidden macro magic is supposed to then make the compiler call the double or float versions as appropriate for the type used. Having said th

Re: Math.h functions with CGFloat

2010-08-10 Thread steven Hooley
Yes, sorry - i meant /usr/include/math.h Because CGFloat is typedef'd to float on 32bit and double on 64bit i have to swap between, eg, atan and atanf depending on my build settings. I have a framework which is intended to support 32bit and 64bit. I thought this may have been a common scenario a

Re: Math.h functions with CGFloat

2010-08-10 Thread Alastair Houghton
On 10 Aug 2010, at 13:42, steven Hooley wrote: > Is there a preferred way to use the Math.h functions with CGFloats > that is 32 and 64 bit safe? Why would they be unsafe? (They aren't.) It's possible that using the double versions (the ones without the "f" suffix) is inefficient in 32-bit mod