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?
Use
%f:Edit:
If you don’t want decimal places you should use:
To elaborate, you were using wrong specifier in format string.
%ginstructs to create string representation of floating-point variable in scientific notation. Normally you should use%fto representdoubleandfloatvariable. 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.3fmeans 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:will give result: