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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:40:13+00:00 2026-06-17T01:40:13+00:00

I realize there have been other questions like this, but my problem does not

  • 0

I realize there have been other questions like this, but my problem does not seem to relate accurately. Here’s the deal.

I have an app, that does a calculation. I am using floats for this. All floats work fine, and I convert the float value into a NSNumber for formatting.

NSNumberFormatter *numFormatter = [NSNumberFormatter alloc];
    [numFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
    [numFormatter setMinimumFractionDigits:1];
    [numFormatter setMaximumFractionDigits:5];

    NSNumber *insulinRatio = [NSNumber numberWithFloat:insulinRatioCalc];
    NSLog(@"Original Number = %@", insulinRatio);

My NSNumber, insulinRatio, has accurate precision. However, when I convert that into an NSString with NSNumberFormatter, it loses all decimal precision.

NSString *numberAsString = [numFormatter stringFromNumber:insulinRatio];
    NSLog(@"Number = %@", numberAsString);

My output for these last logs where the following:

2013-01-08 16:12:27.944 MyApp[84062:c07] Original Number = 1.2
2013-01-08 16:12:27.944 MyApp[84062:c07] Number = 1

Why am I losing this precision. I know that NSNumber converts to double, but the NSNumber is fine here. It is the NSNumberFormatter. What am I doing wrong?

Thanks

  • 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-17T01:40:16+00:00Added an answer on June 17, 2026 at 1:40 am

    Nevermind. I just had to initialize NSNumberFormatter. #fail moment.

    NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc]init]; 
    

    solved the problem. 🙂

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

Sidebar

Related Questions

I realize there have been a few other questions on this topic, and the
I realize there are similar questions on this topic, but I still cannot find
I'm really sorry, I realize there have been several questions asked about cocos2d touch
I realize this question is very likely to have been asked before, but I've
I realize there are other questions on SO regarding animations and progressbars, but they
I realize there are a few other questions about why Cygwin is apparently slow,
I realize there are similar posts to this out there, but rest assured, this
I realize that there are many similar questions, but most involve scaling down the
I realize there have already been a number of posts on n-tier design and
I realize there are several SO questions on the subject and this one describes

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.