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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:14:08+00:00 2026-06-13T21:14:08+00:00

EDIT: Fixed, here is how i did it for furture reference: NSNumber *inputNumber =

  • 0

EDIT: Fixed, here is how i did it for furture reference:

NSNumber *inputNumber = [[NSNumber alloc ]initWithDouble:convertValue];
NSNumber *resultNumber = [[NSNumber alloc]initWithDouble:result];


NSNumberFormatter *formatterResult = [[NSNumberFormatter alloc] init];
formatterResult.numberStyle = NSNumberFormatterDecimalStyle;
NSNumberFormatter *formatterInput = [[NSNumberFormatter alloc] init];
formatterInput.numberStyle = NSNumberFormatterDecimalStyle;

[formatterResult setNumberStyle:NSNumberFormatterDecimalStyle];
[formatterResult setMaximumFractionDigits:6];

[formatterInput setNumberStyle:NSNumberFormatterDecimalStyle];
[formatterInput setMaximumFractionDigits:6];
//These four lines are the one fixing the issue. 


NSString *formattedResultString = [formatterResult stringFromNumber:(NSNumber*)resultNumber];
NSString *formattedInputString = [formatterInput stringFromNumber:(NSNumber*)inputNumber];






NSString *formelString = [[NSString alloc]initWithFormat:
                          @" %@ %@ =", formattedInputString, convertFromName];

formelLabel.text = formelString;


NSString *resultString = [[NSString alloc]initWithFormat:
                          @" %@ %@",formattedResultString, convertToName];

resultLabel.text = resultString;

———-ORIGINAL QUESTION————

So I have a problem with NSNumberFormatter shortening numbers too much, and also not displaying decimals when the main number is over 8 digits.

Problem described in following picture:

enter image description here <- Working, but shortening to three decimals. (And rounding up, which is done mathematically correct)

And then the problems: (Right-most picture is correct)

enter image description here
enter image description here
enter image description here

As you can see, the bottom image just ignores the decimals completely. What code do I need to add/change for this to work properly?

Here is the relevant code:

[super viewDidLoad];

    _convertFrom = @[@"MTPA", @"MMcf/day",
    @"Mill.Sm3/day", @"MMBTU/day", @"Boe/day",@"ton LNG/day", @"GJ/day"];

    _convertTo = @[@"MTPA", @"MMcf/day",
    @"Mill.Sm3/day", @"MMBTU/day", @"Boe/day", @"ton LNG/day", @"GJ/day"];

    _convertRates = @[ @1.0f, @133.3333333f, @3.775579545f,
    @137333.3333f, @23747.68013, @1716.17252, @147247.6022];
//some place down in the code:
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

{

[self updateConversionLabel]; 
}


- (void)updateConversionLabel
{
float convertFrom = [[_convertRates objectAtIndex:[picker selectedRowInComponent:0]] floatValue];

float convertTo = [[_convertRates objectAtIndex:[picker selectedRowInComponent:1]] floatValue];

NSNumberFormatter *fmt = [NSNumberFormatter new];
float input = [fmt numberFromString:inputText.text].floatValue;

float to = convertTo;
float from = convertFrom;

float convertValue = input;
float relative = to / from;
float result = relative * convertValue;

NSString *convertFromName = [_convertFrom objectAtIndex:[picker selectedRowInComponent:0]];
NSString *convertToName = [_convertFrom objectAtIndex:[picker selectedRowInComponent:1]];


NSNumber *inputNumber = [[NSNumber alloc ]initWithFloat:convertValue];
NSNumber *resultNumber = [[NSNumber alloc]initWithFloat:result];


NSNumberFormatter *formatterResult = [[NSNumberFormatter alloc] init];
formatterResult.numberStyle = NSNumberFormatterDecimalStyle;
NSNumberFormatter *formatterInput = [[NSNumberFormatter alloc] init];
formatterInput.numberStyle = NSNumberFormatterDecimalStyle;

NSString *formattedResultString = [formatterResult stringFromNumber:(NSNumber*)resultNumber];
NSString *formattedInputString = [formatterInput stringFromNumber:(NSNumber*)inputNumber];





NSString *formelString = [[NSString alloc]initWithFormat:
                          @" %@ %@ =", formattedInputString, convertFromName];

formelLabel.text = formelString;


NSString *resultString = [[NSString alloc]initWithFormat:
                          @" %@ %@",formattedResultString, convertToName];
                          resultLabel.text = resultString;


}

I’d assume the problem/fix is in this code.

  • 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-13T21:14:10+00:00Added an answer on June 13, 2026 at 9:14 pm

    EDIT: Fixed, here is how I did it for future reference:

    NSNumber *inputNumber = [[NSNumber alloc ]initWithDouble:convertValue];
    NSNumber *resultNumber = [[NSNumber alloc]initWithDouble:result];
    
    
    NSNumberFormatter *formatterResult = [[NSNumberFormatter alloc] init];
    formatterResult.numberStyle = NSNumberFormatterDecimalStyle;
    NSNumberFormatter *formatterInput = [[NSNumberFormatter alloc] init];
    formatterInput.numberStyle = NSNumberFormatterDecimalStyle;
    
    [formatterResult setNumberStyle:NSNumberFormatterDecimalStyle];
    [formatterResult setMaximumFractionDigits:6];
    
    [formatterInput setNumberStyle:NSNumberFormatterDecimalStyle];
    [formatterInput setMaximumFractionDigits:6];
    //These four lines are the one fixing the issue. 
    
    
    NSString *formattedResultString = [formatterResult stringFromNumber:    (NSNumber*)resultNumber];
    NSString *formattedInputString = [formatterInput stringFromNumber:(NSNumber*)inputNumber];
    
    
    
    
    
    
    NSString *formelString = [[NSString alloc]initWithFormat:
                          @" %@ %@ =", formattedInputString, convertFromName];
    
    formelLabel.text = formelString;
    
    
    NSString *resultString = [[NSString alloc]initWithFormat:
                          @" %@ %@",formattedResultString, convertToName];
    resultLabel.text = resultString;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: I fixed the problem by just starting from scratch. Sorry to waste y'alls
Edit: closing anchor fixed. This issue exists when testing on the following browsers: Google
EDIT: I have fixed all but two warnings now, so thank you all for
EDIT : As of 2012-06-11 this bug has been finally fixed! https://bugs.webkit.org/show_bug.cgi?id=35981#c1 I have
Edit : The bug that caused this problem has been fixed. The @version tag
EDIT: See end of my post for working code, obtained from zeekay here .
[EDIT: FIXED! The problem appears to be having an invisible VideoView overlaying my GLSurfaceView
* edit have fixed this code - see inline comments marked EDIT * I'm
EDIT FIXED by user @jeroen You have to move the li and a tags
EDIT: We're in Chrome 19 now, and this still isn't fixed. Just a clarification:

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.