jsguides

Math.LOG10E

Math.LOG10E is a static property of the Math object that represents the base-10 logarithm of E (Euler’s number), approximately 0.4342944819032518. It is a read-only constant; you cannot change its value.

This constant is useful when working with decimal logarithms (log base 10) or converting between natural logarithms and base-10 logarithms. While Math.log10() does the actual computation, Math.LOG10E provides the mathematical constant directly.

Syntax and value

Access Math.LOG10E as a static property on the Math object. It requires no arguments — the value is read directly from the constant, not computed per call. The constant evaluates to approximately 0.4342944819032518, which equals 1 / Math.LN10. Because it is read-only, any attempt to assign a new value is silently ignored.

Math.LOG10E; // 0.4342944819032518

Examples

Basic Usage

To see the constant’s value, log it directly with console.log. The output matches the IEEE 754 double-precision representation that every JavaScript engine stores internally. No calculation is involved — you are reading a precomputed constant directly from the engine.

console.log(Math.LOG10E);
// 0.4342944819032518

Converting between log bases

Multiplying a natural logarithm by Math.LOG10E gives you the base-10 equivalent. The mathematical identity at work is log10(x) = ln(x) × log10(e), and the constant expresses the log10(e) factor directly. The function below implements this conversion for any positive input.

function log10(x) {
  return Math.log(x) * Math.LOG10E;
}

console.log(log10(10));
// 1

console.log(log10(100));
// 2

console.log(log10(1000));
// 3

Relationship with other constants

Math.LOG10E and Math.LN10 are reciprocals — LOG10E = 1 / LN10. This relationship lets you derive either constant from the other, which is useful when a formula is written in terms of one but you only have the other. The following code confirms both values match to full precision.

// LOG10E = 1 / LN10
console.log(Math.LOG10E);
// 0.4342944819032518

console.log(1 / Math.LN10);
// 0.4342944819032518

Practical Calculations

Here the constant is used for real log calculations with several inputs. The commonLog helper wraps the conversion formula, and the final line verifies that Math.log10(Math.E) produces the same value as Math.LOG10E — confirming the identity works both ways.

// Calculate common log (base 10) from natural log
function commonLog(n) {
  return Math.log(n) * Math.LOG10E;
}

console.log(commonLog(2));
// 0.3010299956639812

console.log(commonLog(1000));
// 2.9999999999999996 (approximately 3)

// Verify: log10(e) = LOG10E
console.log(Math.log10(Math.E));
// 0.4342944819032518 (approximately Math.LOG10E)

Scientific notation conversion

The constant converts between natural-log exponents and base-10 exponents. In scientific fields, data often arrives in one logarithmic form and needs to be expressed in the other — multiplying or dividing by Math.LOG10E handles the switch without an extra Math.log10() call.

// Convert between natural log and decimal log
function scientificToDecimal(exponent) {
  return exponent * Math.LOG10E;
}

console.log(scientificToDecimal(1));
// 0.4342944819032518

console.log(scientificToDecimal(2));
// 0.8685889638075036

Comparing logarithm bases

This example confirms that converting a natural log via Math.LOG10E produces the same result as calling Math.log10() directly. The function returns all three values — natural log, decimal log, and the constant-based conversion — so you can compare them side by side.

// Natural log vs base-10 log relationship
function compareLogs(x) {
  const natural = Math.log(x);
  const decimal = Math.log10(x);
  const viaConstant = natural * Math.LOG10E;
  
  return { natural, decimal, viaConstant };
}

const result = compareLogs(100);
console.log(result.natural);
// 4.605170185988092

console.log(result.decimal);
// 2

console.log(result.viaConstant);
// 2

Working with exponents

You can also run the reciprocal relationship in reverse: dividing an exponent by Math.LOG10E converts it from a base-10 exponent back to a natural-log exponent. The output of convertExponent(1) equals Math.LN10, and doubling the input doubles the output linearly.

// Convert exponent in natural base to decimal base
function convertExponent(naturalExponent) {
  return naturalExponent / Math.LOG10E;
}

console.log(convertExponent(1));
// 2.302585092994046 (approximately Math.LN10)

console.log(convertExponent(2));
// 4.605170185988092 (approximately 2 * LN10)

Common Patterns

Logarithmic identity verification

The identity log10(x) = ln(x) × LOG10E can be verified programmatically. The function below compares Math.log10(x) against two alternative derivations — one using Math.LN10 as a divisor and one multiplying by Math.LOG10E. All three paths should produce the same result.

// Verify: log10(x) = ln(x) / ln(10) = ln(x) * LOG10E
function verifyIdentity(x) {
  const direct = Math.log10(x);
  const viaNatural = Math.log(x) / Math.LN10;
  const viaConstant = Math.log(x) * Math.LOG10E;
  
  return { direct, viaNatural, viaConstant };
}

console.log(verifyIdentity(50));
// { direct: 1.69897, viaNatural: 1.69897, viaConstant: 1.69897 }

Creating custom log functions

With Math.LOG10E and Math.log(), you can build a log function for any base by applying the change-of-base formula. The example below computes both log10(100) and log10(e) — the latter should match the value of Math.LOG10E exactly, which is a quick cross-check.

// Create a log function for any base
function logBase(base, x) {
  return Math.log(x) / Math.log(base);
}

console.log(logBase(10, 100));
// 2

console.log(logBase(10, Math.E));
// 0.4342944819032518 (Math.LOG10E)

Converting logs safely

Math.LOG10E is most useful when you already have a natural logarithm and want to express the result in base 10. That is common in science, data analysis, and any code that mixes formulas from different sources. The constant keeps the conversion readable and avoids repeating the reciprocal of Math.LN10 by hand.

Because the value is a floating-point constant, you should still expect tiny precision differences in formatted output. That is normal for JavaScript math. If you need a user-facing display, round or format the result after the calculation instead of comparing the raw value against a hardcoded decimal string.

When to prefer Math.log10()

If you only need a base-10 logarithm, Math.log10() is usually the clearest choice because it states the base directly. Math.LOG10E is more useful when your formula already uses Math.log() and you want to convert the result. The right choice is mostly about intent: use the direct helper when you have it, and use the constant when it fits the algebra you are already writing.

That distinction keeps formulas easy to verify. Someone reading the code can see whether the base-10 value is computed directly or derived from the natural logarithm, which matters when you are checking a formula against a textbook or a scientific reference.

Why use Math.LOG10E?

Using Math.LOG10E instead of hardcoding 0.4342944819032518 provides several advantages:

  1. Precision — The constant is defined to full floating-point precision by the JavaScript engine
  2. Readability — Code clearly expresses the mathematical concept instead of a magic number
  3. Standardization — Matches standard mathematical notation in formulas and textbooks
  4. Self-documenting — The name conveys the mathematical meaning to anyone reading the code
  5. Consistency — Using built-in constants ensures consistency across your codebase

See Also

  • Math.LN10 — the natural logarithm of 10, the inverse of LOG10E
  • Math.log() — returns the natural logarithm of a number
  • Math.log10() — returns the base-10 logarithm of a number
  • Math.LOG2E — the base-2 logarithm of E