log base 2 in c++

#include <iostream>
#include <cmath>

int main() {
    double num, result;

    // Input: Get the number for which the logarithm base 2 is to be calculated
    std::cout << "Enter a number: ";
    std::cin >> num;

    // Processing: Calculate the logarithm base 2 using the log2 function from the cmath library
    result = log2(num);

    // Output: Display the result
    std::cout << "Log base 2 of " << num << " is: " << result << std::endl;

    return 0;
}