So I’ve coded a calculator in objective C and I’ve formatted the display in .4g as I wanted only significant digits and 4 decimal places. This works fine 🙂
What I would like it to do is not display 2.34E+05 etc when it displays a longer number like 234,000. I’ve allowed it to autosize the text in the label so I know it isn’t just that the label is too small.
Is there a piece of code that will make it display the actual number instead of the scientific notation?
So I’ve coded a calculator in objective C and I’ve formatted the display in
Share
Formatting with
%finstead of%gwon’t use standard form.Have a look at this specification.
Edit 1:
I found this answer to help with the rounding.
I then combined these two options to get:
Edit 2:
What about this:
I haven’t tested this, but it looks as if it limits decimals to 5, then removes any trailing zeros or decimal points.
[Source]