开发者

Calculate constant E value

开发者 https://www.devze.com 2023-02-27 05:26 出处:网络
I am doing a calculation in Objective-C. I have one value 4.0468564224e-33. I dont know what that e constant\'s value is. Please h开发者_开发百科elp me: how can I calculate this constant value? How ar

I am doing a calculation in Objective-C. I have one value 4.0468564224e-33. I dont know what that e constant's value is. Please h开发者_开发百科elp me: how can I calculate this constant value? How are constant values declared and calculated in Objective-C?


The e is part of scientific notation.

Most calculators and many computer programs present very large and very small results in scientific notation. Because superscripted exponents like 107 cannot always be conveniently represented on computers, typewriters and calculators, an alternative format is often used: the letter E or e represents times ten raised to the power of, thus replacing the × 10, followed by the value of the exponent. Note that the character e is not related to the mathematical constant e (a confusion that is less likely with capital E); and though it stands for exponent, the notation is usually referred to as (scientific) E notation or (scientific) e notation, rather than (scientific) exponential notation (though the latter also occurs).

4.0468564224e-33 means 4.0468564224 * 10-33, or 0.0000000000000000000000000000000040468564224.


Adding this citation for future users which is reverse of the asked above question. Google brought me here, So I think this is the best place to add this answer.

NSString *num = @"5.0E0";

To get the processed value from above string you need to simply do this:

CGFloat secNum = [num floatValue]; // this will feed 5 to secNum

Hope it could help someone.


If you just need to use e's value you can get it from math.h

#import <math.h>
...

NSLog(@"e: %g", M_E);
0

精彩评论

暂无评论...
验证码 换一张
取 消