find the base 2 logarithm of a number in csharp

To find the base 2 logarithm of a number in C#, you can use the Math.Log method with a base of 2 as the second argument. Here's the code:

main.cs
double num = 64;
double logBase2 = Math.Log(num, 2);
53 chars
3 lines

In this example, we're finding the base 2 logarithm of 64. The Math.Log method returns a double value, which we've stored in the logBase2 variable.

gistlibby LogSnag