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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:57:16+00:00 2026-05-15T08:57:16+00:00

Okay, from what I understand, an integer that is a fraction will be rounded

  • 0

Okay, from what I understand, an integer that is a fraction will be rounded one way or the other so that if a formula comes up with say 5/6 – it will automatically round it to 1. I have a calculation:

xyz = ((1300 - [abc intValue])/6) + 100;

xyz is defined as an NSInteger, abc is an NSString that is chosen via a UIPicker. I want the calculation (1300 – [abc intValue]) to add 1 to 100 for each 6 units below 1300. For example, 1255 should result in xyz having a value of 100 and 1254 should result in a value of 101.

Now, I understand that my formula above is wrong because of the rounding principles, but I am getting some CRAZY results from the program itself. When I punched in 1259 – I got 106. When I punched in 1255 – I got 107. Why would it behave that way?

  • 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-15T08:57:17+00:00Added an answer on May 15, 2026 at 8:57 am

    Your understanding is wrong. Integer division truncates:

    5 / 6 == 0
    
    (1300 - 1259) / 6 == 41 / 6 == 6
    
    (1300 - 1255) / 6 == 45 / 6 = 7
    

    You can use:

    xyz = ((1300.0 - [abc intValue])/6) + 100;
    

    and make xyz a NSDouble. That will ensure it does floating-point division.

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

Sidebar

Related Questions

Okay so from what I've read on other websites and on stack overflow, Rails
Okay so I have a web view that holds the chat bar div from
Okay, so I understand all of us C/C++ programmers have at one time met
I have a function that I dont quite understand There are 109 addresses from
Okay this is one of those situations where I have concluded that I am
Okay, this is following on from my previous question reguarding performing a simple ajax
Okay weirdest thing is happening I separated my navbar from my container and now
Okay, so this is a carry on from my last question, but I have
Is it okay to get a read-only collection from an aggregate without going through
Okay so, I'm currently running this code to move a bunch of data from

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.