API · JavaScript
JavaScript Math.LOG2E Property
Learn what the JavaScript Math.LOG2E property represents, how to access its value, and how to use it in calculations.
On this page
JavaScript’s Math.LOG2E property represents the base-2 logarithm of Euler’s number, written as log₂(e). Euler’s number, e, is approximately 2.71828, so Math.LOG2E is approximately 1.442695. This is a numeric property on the built-in Math object: read it as a value, without parentheses. It is not a method to call.
What Math.LOG2E Represents
A logarithm answers the question “to what power must a base be raised to produce this number?” Math.LOG2E gives the power needed to raise 2 to e: 2 ** Math.LOG2E is approximately e. The property stores a fixed mathematical constant; it does not calculate a new value from an argument.
The name identifies the base and the number: LOG2E means the logarithm of e to base 2. Its value is a JavaScript Number approximation, not an exact representation of the irrational value. Use the constant when a calculation needs this conversion factor, and use an appropriate tolerance when comparing calculated floating-point values instead of requiring exact equality.
Syntax, Parameters, and Return Value
Access the constant with Math.LOG2E. There are no parameters because this is a property, not a function. The expression evaluates to a number, approximately 1.4426950408889634; writing Math.LOG2E() attempts to call that number and is incorrect.
Unlike Math.log2(x), which is a function that accepts a value and returns that value’s base-2 logarithm, Math.LOG2E is the constant 1 / ln(2). The related Math.log(x) function computes the natural logarithm (base e) of x. Keeping these roles distinct helps choose the right expression: call a logarithm function with the input, or read the constant when converting a natural-log result.
Use Math.LOG2E in JavaScript
The constant can participate in ordinary arithmetic. For positive x, the change-of-base relationship gives log₂(x) = ln(x) / ln(2), which is also Math.log(x) * Math.LOG2E. For most direct base-2 calculations, Math.log2(x) is clearer; the multiplication is useful when a calculation already has a natural-log result or when the conversion factor itself is needed.
Run this example:
const value = 8;
console.log(Math.LOG2E);
console.log(Math.log(value) * Math.LOG2E);
console.log(Math.log2(value));
1.4426950408889634
2.9999999999999996
3
Both expressions are mathematically equal to 3 for 8 because 2 raised to the third power is 8. In this run, multiplication returns 2.9999999999999996, a floating-point approximation, while Math.log2(value) displays 3. For another positive input, the same relationship converts its natural logarithm to base 2. The two calculated results can differ slightly for some inputs because JavaScript numbers use finite-precision floating-point arithmetic. If you need a base-2 logarithm of one value, prefer Math.log2(value); if you need to transform Math.log(value) or reuse the conversion factor in a formula, Math.LOG2E provides that factor directly.