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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:44:39+00:00 2026-06-13T00:44:39+00:00

This is literally the weirdest thing I have ever encountered. So, I have a

  • 0

This is literally the weirdest thing I have ever encountered. So, I have a float called ratingDecimal, and I use some conditions to compare it. Here is what the conditions look like:

    if (ratingDecimal >= 0.0) {

    if (ratingDecimal < 0.3 && ratingDecimal != 0.3) {

        ratingDecimal = 0.0;

        NSLog(@"bigger or equal to 0 and smaller than 0.3");
    }
}

if (ratingDecimal >= 0.3) {

    if (ratingDecimal < 0.8 && ratingDecimal != 0.8) {

        ratingDecimal = 0.5;

        NSLog(@"middle");
    }
}

if (ratingDecimal >= 0.8) {

    NSLog(@"bigger or equal to 0.8");

    ratingDecimal = 1.0;
}

Here is a weird problem. I have set the ratingDecimal to 0.8, the console logs ratingDecimal as:

0.8

but calls:

middle

Which should only be called if ratingDecimal is bigger or equal to 0.3 but smaller than 0.8 and DOES NOT equal to 0.8.

The statement that should be getting called is:

if (ratingDecimal >= 0.8) {

NSLog(@"bigger or equal to 0.8"); 

ratingDecimal = 1.0;

}

But I do not see

bigger or equal to 0.8

You are probably wondering why my conditions are so tedious and complex, they can be as simple as:

if (ratingDecimal >= 0.3  < 0.8)

They used to be like that but since this has never worked I kept on breaking the statement down and it is STILL acting weird.

Why is this happening!?

Here is an image example:

PROBLEM

  • 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-13T00:44:40+00:00Added an answer on June 13, 2026 at 12:44 am

    Your ratingDecimal value is probably something like 0.7999999999999. When printed to the console, something is probably rounding it to 0.8, but the comparison still sees it as less than 0.8.

    This is due to the binary nature of floating point numbers. See What Every Computer Scientist Should Know About Floating-Point Arithmetic for extensive information on this.

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

Sidebar

Related Questions

This is literally driving me nuts. I have 2 entities that use NSStrings as
This is literally the first thing I've ever written in C, so please feel
I have been at this literally all day. I can create linked lists no
I have to rewrite some my old code from VB6 to VB.NET and here
I have literally been searching for this for weeks. I am a novice java
I've literally been trying to debug this for a full day and it's utterly
So I am doing this query from PHP, and here listerally the exact query
Typically, I've seen people use the class literal like this: Class<Foo> cls = Foo.class;
I see this all the time: object literals declared such that some keys are
I have a repeater like this: <asp:Repeater runat=server ID=pde> <HeaderTemplate></HeaderTemplate> <ItemTemplate> <asp:Literal runat=server ID=literal1></asp:Literal>

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.