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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:02:48+00:00 2026-06-10T04:02:48+00:00

It might be a simple solution but I can not fix it. I am

  • 0

It might be a simple solution but I can not fix it.

I am dividing 2 integers :

finishedGameFinalScore = [score integerValue];
CGFloat interval = 2/finishedGameFinalScore;
NSLog(@"interval = %f",interval);

The log returns 0.000000

Is there a limit for decimal places? I need to preserve the decimal result.

Thanks
Shani

  • 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-10T04:02:49+00:00Added an answer on June 10, 2026 at 4:02 am

    The reason your code doesn’t work is that you’re dividing an integer by another integer and then casting the result to a float.

    So you have 2 (an integer) and some other number (also an integer). Then you divide 2 by this number – which is probably greater than 2. Let’s say it’s 3.

    Integer sees 2/3 and he’s like “0.66666667? Pshh, no one ever needs anything after the decimal point anyway”. So he truncates it. You just have 0.

    Then Integer gives the number to Mr. float and Mr float is super happy to get a number! He’s all like “yay, a 0! I’m going to add ALL OF THE SIGNIFICANT DIGITS”. And that’s how you end up with 0.0000000.

    So yeah, just cast to a float first. Or even a double!

    enter image description here

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

Sidebar

Related Questions

I have a simple problem but have not figured out what might be solution
might be a stupid simple solution but I can't seem to find what's wrong
this might look simple but i am not able to Find the solution for
There might be a really simple solution to this question, but i just don't
I know it might be a very simple solution for this, but I am
Ok, this might sound simple but am not sure what to do. I am
This might be a simple question but I've searched and searched and can't find
This might be a simple question, but i can't seem to grasp it. I
This might be simple but I am new to Oracle. I am using Oracle
This might be a simple answer, but I am having some issues writing this

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.