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

  • SEARCH
  • Home
  • 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 8117181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:04:45+00:00 2026-06-06T04:04:45+00:00

I am making a grading App for my students, but my comparison operators are

  • 0

I am making a grading App for my students, but my comparison operators are not functioning they way I expect them to. My code is as follows;

float FINAL = ((_gradeyouwant - (_quarter1 * 0.2f) - (_quarter2 * 0.2f) - (_quarter3 * 0.2f) - (_quarter4 * 0.2f) - (_quarterM * 0.1f)) / 0.1f);

NSLog(@"q1 = %.2f", _quarter1);
NSLog(@"q2 = %.2f", _quarter2);
NSLog(@"q3 = %.2f", _quarter3);
NSLog(@"q4 = %.2f", _quarter4);
NSLog(@"qM = %.2f", _quarterM);
NSLog(@"qF = %.2f", FINAL);
NSLog(@"grade = %.2f", _gradeyouwant);

if ((FINAL > 4.3f))
{
    [_result setText:[NSString stringWithFormat:@"It is not possible to get your desired grade."]];
}else if ((FINAL > 4.0f))
{
    [_result setText:[NSString stringWithFormat:@"You would need to get an A+"]];
}else if ((FINAL > 3.7f))
{
    [_result setText:[NSString stringWithFormat:@"You would need to get an A"]];
}else if ((FINAL > 3.3f))

ETC. ETC.

When you look at the output with NSLog, it tells me the correct value of everything. However, if I make it so the FINAL is 4.0, it does not print the correct string. I was figuring that when it got to the FINAL > 4.0, it would not run that line. But it does. What am I doing wrong? Thanks so much in advance!

  • 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-06T04:04:47+00:00Added an answer on June 6, 2026 at 4:04 am

    This is pretty much how floats work. Google it, e.g. http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

    The system may not be able to precisely store 4.0. It’s more a limitation of your CPU and choice of data types. Using a range may very well work.

    I’d use an int and emulate the decimal digits, e.g. GPA * 100.

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

Sidebar

Related Questions

Im making a PyQt4 app which calls Imagemagick and ffmpeg, but it takes too
Making a simple map app, plan on adding buttons to mark specific locations But
Making UI programmatically is very powerful. But is there a way I would have
Making a new site but something is happening to it in IE8. The social
Making a new site but something is happening to it in IE. I've purchased
Making an Flex App. Just wondering if anyone has created something that fits automatically
Making a search result list (like in Google) is not very hard, if you
Making a piano/keyboard application and trying to figure out the best way to set
Making good progress on rails now, but hit a snag on heroku deployment. After
Making a game with OpenGL/GLUT and C++. I've heard the easiest way to manage

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.