So I'm trying to figure out the best way to solve simple logarithms using objective c. For example ln 30 = 3.4012. I'm not too sure if there's any built in functionality in objective c to do this. Any ideas?
Asked
Active
Viewed 822 times
1
-
Possible duplicate: http://stackoverflow.com/questions/891963/what-kind-of-logarithm-functions-methods-are-available-in-objective-c-cocoa – Luke Apr 03 '12 at 06:20
2 Answers
4
In fact it is "c" question because Objective-C is based on c, and all primitive math functions like logarithms are included in math.h so use:
log() to find logarithms
exp() to find exponent e.g.
NSLog(@"log(30.0):%f", log(30.0));
NSLog(@"exp(3.4012):%f", exp(3.4012));
>
log(30.0):3.401197
exp(3.4012):30.000079

Vladimir
- 7,670
- 8
- 28
- 42
3
Objective C is compatible with and includes all of standard C, so you can use the log() and exp() functions by importing math.h.

hotpaw2
- 70,107
- 14
- 90
- 153