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 8670513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:43:26+00:00 2026-06-12T18:43:26+00:00

I am trying to compare a CGFloat to an integer value. Based on this

  • 0

I am trying to compare a CGFloat to an integer value. Based on this value, execute a conditional… pretty standard. However, this will always be true for some reason. I even print out the values and they are clearly less than 800…. I have tried a bunch of different combinations, the most recent is shown below, I thought maybe it was comparing the size of float and the size of the int based purely on its binary values, so I tried this risky little cast operation… Any ideas?

CGPoint textViewPoint = [scroller convertPoint:[textView center] toView:(UIView *)self.view];
        NSLog(@"the y coord is %f", textViewPoint.y);

    int size = (int)textViewPoint.y;
    NSLog(@"the yint %d", size);
    //move the main view, so that the keyboard does not hide it.
    //if  (self.scroller.frame.origin.y >= 0 && textViewPoint.y > 800.0);
    if(size > 800);
    {
        NSLog(@"moving up");
  • 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-12T18:43:27+00:00Added an answer on June 12, 2026 at 6:43 pm

    The problem is the ; at the end of the if(size > 800); line, not the int vs. float comparison. Remove it and all should be OK.

    This is because this semicolon is interpreted as the body of your if statement, and that’s this NO-OP statement that is executed when the condition is true. Then, the rest of your code next to this if empty body is outside of the if body so is executed whatever the condition value. That’s exactly as if you had written:

    if(size > 800)
    {
    }
    {
        NSLog(@"moving up");
    }
    

    Compiler Warning Tip

    The compiler generally warns you about this mistake. Be sure that you have the “Empty Loop Bodies” warning activated in your project Build Settings (compiler flag -Wempty-body): this way the next time you do this mistake, you will have a warning about it and will know what is wrong and how to fix it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to 'compare' all documents between 2 collections, which will return true only
When trying to compare software versions 5.12 to 5.8, version 5.12 is newer, however
Trying to compare voids for a sorting algorithm. I have this so far but
i'm trying to compare a value from an HTML label, but can't parser it.
I'm trying to compare a character string with the argv argument. I have this
I'm trying to compare an integer and a double: printf(%d\n, pos<(td+tr)); if(td <= pos
I'm getting this warning when I'm trying to compare RGB components of two UIColors
I am trying to create this method. Let's call this -(NSMutableArray*) getEightClosestSwatchesFor:(CGFloat)hue { NSString
I'm trying to compare two DataRow s in a loop. However, the following if
Hi I am trying to compare a cell value in the spreadhseet with a

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.