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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:44:38+00:00 2026-05-26T15:44:38+00:00

Right, I have an array for floats which stores only 1s and 0s. I’m

  • 0

Right, I have an array for floats which stores only 1s and 0s. I’m trying to just do a simply test/check that the current slot in the array is 1 it will print out a little message to say it is 1, otherwise, it is 0. Heres my code:

if(myArray[i] == 1)
{
    cout << "this is 1 !!!!!" << endl;
}
else
{
    cout << "this is 0 ";
}

but this just keeps entering the “else” section. i.e. only printing “this is 0”. Whats wrong with it (or whats wrong with me?? :P)??

  • 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-05-26T15:44:38+00:00Added an answer on May 26, 2026 at 3:44 pm

    Great link: What Every Computer Scientist Should Know About Floating-Point Arithmetic

    After reading that you’ll realise that the floating-point representation of 1 isn’t quite the integer value 1. It’s close, but not quite, and that’s why your condition will always be false.

    Why would you use floats to store boolean data? Use an array of bools or a bitvector.

    EDIT: I can’t actually think of any situation where (or why) you’d compare floats to a literal, anyone know any?

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

Sidebar

Related Questions

I'm trying to create an array of a struct, which I have done and
i have a website page that contains only data of which one field gives
Right now I have def min(array,starting,ending) minimum = starting for i in starting+1 ..ending
Right now, I have this code where $obj_arr maybe contain array and an object.
I hope I can explain this right I have two input fields that require
Right now I have a database (about 2-3 GB) in PostgreSQL, which serves as
Right now I have an SSIS package that runs every morning and gives me
I have a function from an external source that returns an array of 2
Hi this is my algorithm which takes an array with float numbers that are
I have a varray full of triangles that make a large square. I'm trying

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.