On Wed, 17 Mar 2010 16:14:38 -0600, Michael Vannorsdel said:

>I've been working on some 64bit code cleaning but need some advice on
>float constants.  Currently on 32bit builds I use -fsingle-precision-
>constant since most of my code uses CGFloats and I'd like the constants
>to be the correct precision.  But in some places I do work with doubles
>and would like the constants involved to be double on 32bit and not
>float getting promoted.  I tried the L suffix on them but they still
>compile as floats.  So is there a way to force a constant to be a double
>when using -fsingle-precision-constant?

I don't see any Cocoa question here... The Xcode list would have been better.

But anyway, CGFloat is sometimes float sometimes double, so how does -
fsingle-precision-constant help you?

Still, CGFloat is a pain when using the 64 to 32 bit truncation warning
and doing something like:

NSRect foo = NSMakeRect (1.0, 2.0, ...)

it will warn building as 32 bit since it's implicitly converting double
to float.  You could do:

NSRect foo = NSMakeRect ((CGFloat)1.0, (CGFloat)2.0, ...)

But that's too ugly IMHO.  My solution is:

NSRect foo = NSMakeRect (1.0f, 2.0f, ...)

which has no warnings in 32 nor 64.  It would be nice if we could write
something like:

NSRect foo = NSMakeRect (1.0cg, 2.0cg, ...)

--
____________________________________________________________
Sean McBride, B. Eng                 [email protected]
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to