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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:49:25+00:00 2026-06-17T18:49:25+00:00

My objective is to create a customer calculator application for iPhone and I am

  • 0

My objective is to create a customer calculator application for iPhone and I am using Xcode to write my application. My problem, that I cannot find a solution for, is how to format a number that uses decimals (with extra zeros) without switching into scientific notation

I tried…

buttonScreen.text = [NSString stringWithFormat:@"%0.f",currentNumber];

%0.f formatting always rounds so if the user types in “4.23” it displays “4”

%f formats numbers with 6 decimals (typing in ‘5’ displays as ‘5.000000’), but I don’t want to show extra zeros on the end of the number.

%10.4f is something else that I have seen in my reading to find the solution, but my problem is that I don’t know how many decimals will be in the answer, and I may want zero decimals or 10 decimals depending on the number.

The following are examples of numbers I’d like to display (without the commas): A whole number larger than 6 digits, a decimal number with more than 6 digits.

123,456,789;
0.123456789;
12345.6789;
-123,456,789;
-0.23456789;
-12345.6789;

*This is a spiritual repost to my earlier question “How to Format Numbers without scientific notation or decimals” which I poorly phrased as I intended to write ‘unnecessary (extra zeros),’ but upon rereading my post clearly witnessed my inability to convey that at any point in my question.

  • 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-17T18:49:26+00:00Added an answer on June 17, 2026 at 6:49 pm

    Use the NSNumberFormatter class.

    First define the formatter:

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

    Then you can define various properties of the formatter:

    formatter.numberStyle = NSNumberFormatterDecimalStyle;
    formatter.maximumIntigerDigits = 3;
    formatter.minimumFractionDigits = 3;
    formatter.maximumFractionDigits = 8;
    formatter.usesSignificantDigits = NO;
    formatter.usesGroupingSeparator = YES;
    formatter.groupingSeparator = @",";
    formatter.decimalSeparator = @".";
    ....
    

    You format the number into a string like this:

    NSString *formattedNumber = [formatter stringFromNumber:num];
    

    Play around with it. Its pretty simple, but may take some work to get the look you would like.

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

Sidebar

Related Questions

My objective is to create a customer calculator application for iPhone and am using
Im trying to create a iPhone Objective C login page using PHP/MySQL to authenticate.
I want to create an objective c application that interprets a list of .aiml
My end objective is to create an applescript that intelligently inserts a bullet point
I need to create an Objective-C method that converts an int into a byte
I'm trying to create an objective C classe for my iPad application which can
Objective: I want to create a web service that allows me to connect to
How to create a TCP socket using Objective-C, check if some TCP ports are
My objective is create an apache module that will provide RESTful services (i.e., we
The objective is to create a custom route so that /undead will go to

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.