Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8977893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:28:42+00:00 2026-06-15T19:28:42+00:00

When setting whole CGFloat values (and thus by implication float and double values) is

  • 0

When setting whole CGFloat values (and thus by implication float and double values) is it best practice to include the decimal point or does it not matter? For example:

CGRect rect1 = CGRectMake(0, 10, 100, 200);         // Approach 1
CGRect rect2 = CGRectMake(0.0, 10.0, 100.0, 200.0); // Approach 2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:28:43+00:00Added an answer on June 15, 2026 at 7:28 pm

    The compiler will do an implicit conversion to float, so either method should result in the same float value.

    However, your Approach 2 is actually specifying a value of type double, which is then converted to float. To explicitly specify a float you need to add an f suffix ie 200.0f

    Personally I always specify values like this as xxx.0f just to keep reminding me that they are floats, and screw the extra work the compiler has to do to interpret my code – it’s there to do my bidding, not the other way around.

    Of course I would also do:

    static const float left = 0.0f;
    static const float top = 10.0f;
    static const float width = 100.0f;
    static const float height = 200.0f;
    
    CGRect rect3 = CGRectMake(left, top, width, height);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Number of pixels width and height does not always tell the whole story. That
i am using Codeigniter i am facing an issue while setting the values of
I am setting NSMutableArray values on class2. Array is filled and retained while executing
Setting default values for System Configuration fields is well understood (via Chapagain and blog
I want to send a POST request with Python, setting the whole POST body
Already whole day I am struggling with setting up the Solr for searching with
I'm getting floating point values like (471, 326.723333333333) from calling MouseEventArgs.GetPosition() on my border
I have a problem with setting up my menu for a website. The whole
so here's the setting: The whole site is working fine if I remove the
alt text http://img375.imageshack.us/img375/9830/combobox.png Setting the IsHitTestVisible=false has the effect of having the whole ComboBox's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.