Home c++ Logarithm base in C++

Logarithm base in C++




has two variables: x and y. you need to calculate the logarithm of x to base y. how to implement it?
the standard log function counts only natural logarithms and base 10 logarithms

Answer 1, authority 100%

A bit of school mathematics … The properties of logarithms are below. Take a close look at the tenth property. Explain in more detail? 🙂

For example, the base 5 logarithm of x is calculated as

log (x) / log (5)

 enter image description here

Answer 2, authority 14%

The standard function std :: log does not count the decimal logarithms, but counts natural logarithms. There is also std :: log10 , std :: log2 , std :: log1p . For the rest, count using the following property, which follows from the definition of the logarithm function:

 enter image description here

Doca – https://en.cppreference.com/w/cpp/header / cmath .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions