• 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: How to disable 'warning: converting to 'int' from 'float'' warning?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to disable 'warning: converting to 'int' from 'float'' warning?


  • Subject: Re: How to disable 'warning: converting to 'int' from 'float'' warning?
  • From: Alastair Houghton <email@hidden>
  • Date: Thu, 6 Oct 2005 23:52:20 +0100

On 6 Oct 2005, at 19:15, Sean McBride wrote:

Hello,

How does one disable the warning "warning: converting to 'int' from 'float'".

I know I could cast, but there are too many. :(

Just cast. If it's your intention to convert a float to an int, you should
have a cast there to show that; otherwise the code isn't clear. Don't believe
the dogma about casts being bad... trying to avoid them by disabling warnings
is *far* worse.


Also, on PPC, this warning is telling you about a performance problem, so
you might not want to ignore it.


Indeed, if you have a lot of casts, you may find that your code runs faster
if you eliminate some by selectively changing the types of your variables;
remember, floats and doubles can hold integer values, and you can round and
truncate to your heart's content with functions like ceil() and floor().
Even on x86, which has fast int<->float conversions, you might find it runs
faster because you won't be using precious integer registers.


(Having not seen your code, of course, this is all very general advice.
Maybe it doesn't apply to you for some reason, or maybe you really have
your heart set on turning off this warning rather than changing the code.)


Kind regards,

Alastair.

--
http://www.alastairs-place.net


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: How to disable 'warning: converting to 'int' from 'float'' warning?
      • From: "Sean McBride" <email@hidden>
References: 
 >How to disable 'warning: converting to 'int' from 'float'' warning? (From: "Sean McBride" <email@hidden>)

  • Prev by Date: RE: Carbon app converting from Xcode 1.5 to Xcode 2.1
  • Next by Date: re: link error: is input for the dynamic link editor, is not a relocatable by the static link editor again
  • Previous by thread: How to disable 'warning: converting to 'int' from 'float'' warning?
  • Next by thread: Re: How to disable 'warning: converting to 'int' from 'float'' warning?
  • Index(es):
    • Date
    • Thread