• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Float constants
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Float constants


  • Subject: Re: Float constants
  • From: "Sean McBride" <email@hidden>
  • Date: Wed, 17 Mar 2010 18:26:14 -0400
  • Organization: Rogue Research Inc.

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@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Float constants
      • From: Manfred Schwind <email@hidden>
    • Re: Float constants
      • From: Nick Zitzmann <email@hidden>
References: 
 >Float constants (From: Michael Vannorsdel <email@hidden>)

  • Prev by Date: Re: setStringValue problems with dynamically loaded views.
  • Next by Date: Re: CoreData database sharing and migration
  • Previous by thread: Float constants
  • Next by thread: Re: Float constants
  • Index(es):
    • Date
    • Thread