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

  • Home
  • SEARCH
  • 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 7919897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:01:18+00:00 2026-06-03T16:01:18+00:00

setMaximumFractionDigits is not working with the following code. NSString *input=@80.90; NSNumberFormatter *numberFormatter=[[NSNumberFormatter alloc] init];

  • 0

setMaximumFractionDigits is not working with the following code.

NSString *input=@"80.90";
NSNumberFormatter *numberFormatter=[[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
[numberFormatter setMaximumFractionDigits:2];
NSNumber *number=[numberFormatter numberFromString:input];

number gets converted to 80.90000000000001. but I have put a limit to 2 decimal places.
So, how do I get number as 80.90, instead of 80.90000000000001

  • 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-03T16:01:21+00:00Added an answer on June 3, 2026 at 4:01 pm

    setMaximumFractionDigits and setMinimumFractionDigits used to formatting a number. or in other words it get applied while converting a number into string i.e. stringFromNumber. So it will not get applied when you are using numberFromString

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

Sidebar

Related Questions

I have a NSNumberFormatter instance like this: NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter
I have this block of code executed when pressing a number: NSString *currentValue =
I'm using the NSNumberFormatter to format currency but the formatter is not working when
I have the following code : NumberFormat nf=NumberFormat.getInstance(Locale.FRANCE); nf.setMinimumFractionDigits(3); String s= nf.format(3456.32); // double
I have write following code to show bar plot annotation. Annotations are shown but
Here is my code : NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(14); nf.setMinimumFractionDigits(0); double d =
The following code: DecimalFormat df = new DecimalFormat(); df.setMinimumFractionDigits(2); int zahl1 = 10; int
Hi all I am using below method to get string from NSNumber -(NSString *)stringFromNumber:(NSNumber
Please can you tell me why my NSNumberFormatter is only letting me use 4
I made a small dialog with a JFormattedTextField, to enter a Float number between

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.