Exponent value not displaying,what should i do?
how to display exponent value after calulation to textbox in iphone sdk.For example say 6.4516e-10.i am not getting answer for it in my开发者_如何学C textbox after calculating 10 * 6.4516e-10.please tell me solution..
Use StringWithFormat and exponent formations:
From the man page on printf:
eE The argument is printed in the style e `[-d.ddd+-dd]' where is one digit before the decimal point and the number after is equal to the precision specification for the argument; when the precision is missing, 6 digits are produced.
So you would want a format something like: %.4e
float n = 6.4516e-10;
n = n * 10;
NSLog(@"n: %.4e", n);
2011-08-29 07:36:38.158 Test[39477:707] n: 6.4516e-09
精彩评论