Is there a way to implement the math function Log() into an equation with an iphone app? im working on right now that without the log function requires about 400 + if and else if statements. I have already wrote out these if and else if statements. half of them work and the other half keeps returning 0.00 . after HOURS of trying to find the problem and compare it to the part that does work i can still not figure it out. i know i can do simple math (add, subtract, divide, mulitply, etc), but i havnt found anything searching forums, google, etc that tells me how to add a Log function. if i could do this i can cut my code down from like 500 lines to about 40 tops. can anyone help me with this or at least point me in the right direction as to where i can find a thread or tutorial on this?
Share
I already fixed Shaun’s example code posted in his answer, but just to be perfectly clear, there were two issues at work:
<math.h>and usinglogfrom the system math library..19077f(logf(abNeckFactor)); we often write mathematics this way, but it is not syntactically valid C (or Obj-C) code.Shaun, I would advise you to spend some more time reading up on what’s available in C and Objective-C; an enormous amount of functionality is present in the language, and a few hours spent learning about what’s already done for you will spend you many, many hours of searching for things in the future.
Note also that the
logfunction is the base-e logarithm. Many people in technical fields outside of mathematics and computing uselogto refer instead to the base-10 logarithm; if that’s what you need, you will want to calllog10( )— orlog10f( )— instead.