Log Base 2 Calculator
Find log base 2 of any number or work backward to the number. A free binary logarithm calculator with change of base, bit width, and the product and quotient rules.
https://hexacalculator.com/calculators/mathematics/arithmetic/log-base-2-calculator
Mathematics
Arithmetic
Log Base 2 Calculator
Find log base 2 of any number or work backward to the number. A free binary logarithm calculator with change of base, bit width, and the product and quotient rules.
Log Base 2 Calculator
Explore the product and quotient rules
Bring in a second number to see how logarithms turn multiplication into addition.
Enter a number to get its base-2 logarithm, or enter a logarithm to recover the number. The base stays at 2 unless you change it.
Please input values into the fields
Was this calculator helpful?
It takes one click and shapes what we fix next.
Add as preferred on GoogleShow the logarithm curve
Plot y = log of x for your base and mark where your number lands.
Show the powers table
List the powers of your base that bracket your number.
The base-2 logarithm answers a small question that comes up all the time when computers do calculations. Specifically, how many times do you have to double 1 to get some value? If you double it three times, you get 8, so the binary logarithm of 8 is 3.
This calculator can calculate this relationship in both directions. Enter a value to get the logarithm or enter a logarithm to find the corresponding value. It also can be used as a general log calculator by changing the base with 2 being the default.
What is a base-2 logarithm?
A logarithm is the inverse function to exponentiation. In other words, the binary logarithm asks the question: what is the power that I need to raise 2 to in order to get your number?
If you type in 16, the result is 4. That's because 2 to the power of 4 equals 16. If you type in 1, you get 0. That's because any number raised to the power of zero equals 1.
Numbers that are not integer powers of 2 give fractional results. The binary logarithm of 3 is approximately 1.585, since three lies between the first power of two and its square.
How does the calculator work?
Most software programs do not directly calculate logarithms to base 2. Instead they use the change of base formula and compute log2(x) as loge(x)/loge(2).
This method can be used for any base. This allows logarithms with different bases (e.g., 2, 10) as well as natural logarithms to be handled in the same program. When the field for the base is changed, the results, curves and power tables change accordingly.
Reading results from three perspectives
When a logarithm is entered in one field the corresponding number value can be calculated. Conversely when a number value is entered in one field then the calculator will perform the inverse operation and calculate the value that raised to the power of the given base would result in. So x = 64 gives log as 6, and log 6 gives x = 64.
Conversely, when a base is entered in the field, the calculator will calculate the base that links the numerical value to the exponent. This is a third, less common possibility. It is useful if one knows both input and output and wants to find the intervening base.
Applications of logarithms with base 2 include:
They are often used in algorithm analysis. When a textbook says that the computational complexity of a method is "log n", this is usually log base 2. This is because the amount of work gets halved at each step. To search through a sorted list with one million items using binary search, you would need about 20 comparisons. That's because the log base 2 of one million is approximately 19.93.
Another common use is to calculate the number of bits required. To encode as many different values, take the base-2 logarithm of the number of values and round up. This is the bit width given in this calculator. So 8 bits fits 256 values, and a field with 32 bits has an upper limit of about 4.3 billion.
In information theory, surprisal is measured in bits, which are directly derived from the logarithm base 2. The outcome of a fair coin toss has one bit of surprisal, and a fair six-sided die roll has about 2.585 bits per roll.
The same unit is also used in other areas where doubling is involved. An octave in music doubles the frequency, and mipmap levels in graphics reduce resolution by a factor of two. Also, the fast Fourier transform is most efficient when the input size is a power of two.
Turn multiplication into addition.
The most profound principle of logarithms is that they turn multiplication into addition. When you multiply two numbers together, their logs add up, and when you divide them, their logs subtract.
Open up the rules for logarithms and check this process with another number of your choice. The power rules follow a similar principle: the exponent is moved to become a multiplier in front of the log.
Understand results at a glance.
Powers of two give whole numbers. So 2, 4, 8, 16, 32 and 64 become 1, 2, 3, 4, 5 and 6 respectively. All the values in between are fractions. Also all the numbers from 0 to 1 are negative since the binary logarithm of half is -1.
To quickly estimate in your head, count how many times you can keep dividing a number by two before it gets below one. If you divide 100 over and over again, it takes about seven times, but the binary logarithm of 100 is actually approximately 6.644.
The following table shows three different logarithms for the same input, which makes it easy to compare between bases.
Number x | Base 2 | Base 10 | Natural (e) |
|---|---|---|---|
2 | 1 | 0.301 | 0.693 |
8 | 3 | 0.903 | 2.079 |
100 | 6.644 | 2 | 4.605 |
1024 | 10 | 3.010 | 6.931 |
Frequently asked questions
What is the difference between a logarithm base 2 and ln or log?
The concepts are the same but the bases differ. A logarithm with base 2 calculates the number of doublings. The natural log ln uses the Euler's number e, which is approximately 2.718 and a logarithm without a base usually refers to a logarithm with base 10. In computer science "log" often refers to a logarithm with base 2. All these are related by constants. A logarithm with base 2 is the result of dividing the natural log by the natural log of 2.
How many bits are required to represent a number?
To encode the number of different values, calculate the base-2 logarithm of that number and round up. This is the bit width specified in this calculator. For example, 256 values fit into 8 bits and 65,536 values fit into 16 bits. Signed integers need one bit reserved for the sign, so an 8-bit integer has a range of -128 to 127.
What do negative logarithms represent?
The value is between 0 and 1. The binary logarithm of a half is -1. Halving one gives you a half, and the log of a quarter is -2. Negative results only come from counting backwards doublings.
Why does the calculator reject zeros and negative numbers?
The logarithm of real numbers is only defined for positive inputs. The log of 0 approaches negative infinity and the log of negative numbers exists only in the complex plane which is outside the scope of this tool.
Can you use bases other than 2?
Yes. The default setting for the "base" field is 2, but you can also enter a value such as 10 to calculate the decimal logarithm, or any base greater than 0 and not equal to 1. Then the calculator will perform calculations in the same way and redraw the curve and potential table according to the selected base.
Related calculators






Disclaimer: This calculator is provided for general informational and educational purposes only. Our calculators are under active development, and results may be inaccurate, incomplete, or unsuitable for your situation. Always verify the figures independently and seek advice from a qualified professional before relying on them. We make no warranties and accept no liability for any loss or decision arising from use of this tool.
References
- Khan Academy: Intro to logarithms
Foundations of logarithms, change of base, and the log rules.
- NIST Digital Library of Mathematical Functions: Logarithms
Reference definitions and identities for the logarithm function.