Is there a function or any other way to calculate in C the logarithm of base x, where x is an integer variable of my program?
Is there a function or any other way to calculate in C the logarithm
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
C doesn’t provide functions to compute logarithms of any bases other than
eor10.So just use math:
If you’ll be doing the logarithms over the same base repeatedly, you can precompute
1/log(b).I wouldn’t rely on the compiler being able to do this optimization for you.