Math.LN10
Holds the natural logarithm of 10, roughly 2.302585092994046.
Math.LN10- Added in JavaScript ES1
Return value
numberThe closest double-precision value to ln(10), 2.302585092994046.
Errors
Nothing on read. Assigning to it is silently ignored in sloppy mode and throws a TypeError in strict mode or a module, because the property is non-writable.
Math.LN10 is a static data property holding the natural logarithm of 10. Its classic use is base conversion: Math.log(x) / Math.LN10 was how you took a base-10 logarithm before Math.log10() was added.
When to reach for it
Reach for the constant when ln(10) is genuinely a term in your formula — converting between natural and decimal logarithms symbolically, or scaling a rate expressed per decade rather than per e-fold. It also turns up in decibel and pH work, though those are usually cleaner written with Math.log10().
What trips people up
This is the constant where the two-rounding problem is visible rather than theoretical. Math.log(1000) / Math.LN10 evaluates to 2.9999999999999996, not 3. The moment that feeds Math.floor() — counting digits, picking a magnitude bucket, choosing an axis tick — the answer is off by one: a digit counter written as Math.floor(Math.log(n) / Math.LN10) + 1 reports 3 digits for 1000 and 6 for a million. Math.log10() is a single operation and returns exactly 3, so use it for every base-10 logarithm.
The property is non-writable, non-enumerable and non-configurable.
Example
When to use it
- Converting a natural logarithm into a base-10 logarithm in legacy code
- Rescaling a growth rate expressed per decade into a continuous rate
- Deriving log2(10) as Math.LN10 / Math.LN2 for base-conversion maths
- Writing decibel or pH formulas where the base-10 log is spelled out
Frequently asked questions
Why does Math.log(1000) / Math.LN10 give 2.9999999999999996?
Because the division rounds twice — once for the natural logarithm and once for the quotient — so the result falls a fraction short of 3. Use Math.log10(1000), which the engine computes directly and returns as exactly 3.
When should I use Math.LN10?
When ln(10) itself is a term in your formula, such as rescaling a rate expressed per decade or converting symbolically between log bases. For plain base-10 logarithms, call Math.log10() instead.
What is the value of Math.LN10?
2.302585092994046, the closest double-precision number to ln(10). It is non-writable, non-enumerable and non-configurable, so it cannot be reassigned.
More examples
Decibels and pH
Doubling an amplitude is 6.020599913279624 dB and a tenfold increase is exactly 20 dB. Neutral water at 1e-7 M gives a pH of exactly 7; the acidic sample comes out near 3.6. Using Math.log10 keeps the round decade values exact.
// Amplitude ratio to decibels
const dB = (ratio) => 20 * Math.log10(ratio);
console.log(dB(2));
console.log(dB(10));
// pH from hydrogen ion concentration
const pH = (molar) => -Math.log10(molar);
console.log(pH(1e-7));
console.log(pH(2.5e-4));Converting between logarithm bases
The same natural logarithm is rescaled into base 10 and base 2 by dividing by the matching constant. The last two lines show the ratio of the constants reproducing log2(10) as 3.3219280948873626 against Math.log2's 3.321928094887362 — a final-bit difference from the extra rounding.
const x = 500;
console.log(Math.log(x)); // natural
console.log(Math.log(x) / Math.LN10); // base 10
console.log(Math.log(x) / Math.LN2); // base 2
console.log(Math.LN10 / Math.LN2); // log2(10)
console.log(Math.log2(10));Order of magnitude, done safely
The Math.log10 column gives 0, 1, 2, 3 and 4 as expected. The Math.LN10 column matches on most inputs but drops 1000 to magnitude 2, which is exactly the off-by-one that makes axis ticks and digit counts go wrong.
const magnitude = (n) => Math.floor(Math.log10(Math.abs(n)));
for (const n of [7, 99, 100, 1000, 45678]) {
console.log(n, magnitude(n), Math.floor(Math.log(n) / Math.LN10));
}
Discussion