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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:21:40+00:00 2026-06-09T13:21:40+00:00

For the code below: double j1; j1=7000000 //example ItemE[5]=[NSString stringWithFormat:@@1. total inc = %g,

  • 0

For the code below:

double j1;

j1=7000000    //example
ItemE[5]=[NSString stringWithFormat:@"@1. total inc = %g", j1];

ItemE[5] is returned as "1.total inc = 7e +06"

How do I prevent the scientific notation and have "1.total inc = 7000000" instead?

  • 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-09T13:21:42+00:00Added an answer on June 9, 2026 at 1:21 pm

    Use %f:

    ItemE[5]=[NSString stringWithFormat:@"@1. total inc = %f", j1];
    

    Edit:

    If you don’t want decimal places you should use:

    ItemE[5]=[NSString stringWithFormat:@"@1. total inc = %.f", j1];
    

    To elaborate, you were using wrong specifier in format string.%g instructs to create string representation of floating-point variable in scientific notation. Normally you should use %f to represent double and float variable. By default, this specifier will result in number with 6 decimal places. In order to change that you can modify that specifier, for example:

    %5.3f means that string should have 3 decimal places and should be 5 characters long. That means that if representation would be shorter than 5 chars, string will have additional spaces in front of number to give 5 chars total. Note that if you will have large number, it’ll not be truncated. Consider code:

    double pi = 3.14159265358979323846264338327950288;
    NSLog(@"%f", pi);
    NSLog(@"%.3f", pi);
    NSLog(@"%8.3f", pi);
    NSLog(@"%8f", pi);
    NSLog(@"%.f", pi);
    

    will give result:

    3.141593
    3.142
       3.142
    3.141593
    3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have difficulties calculating percentage of a double value. I wrote the code below
Code below is working well as long as I have class ClassSameAssembly in same
How to convert the below code double sumxy = 0; for (int i =
Questions - (Relative Code Below) I have a custom class which is a BindableDictionary().
The code below shows a rectangle class using double points, which are also stored
I need to replace : with double backslash \\ but the code below is
I have the code below which works fine, but if I leave the text
Consider the below code fragment: double * p = new double[16]; int value =
I have written code below.but it will print this exception and i really don't
Hi I have written such a code below but it returns wrong output which

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.