JS Built-ins
← Math18 / 215
MathLOG2Eintermediate

Math.LOG2E β€” use converting natural log to log2

πŸ“– Usage Example
// Base-2 logarithm of e
Math.LOG2E   // β†’ 1.4426950408...
// Equivalent to: 1 / Math.LN2

Use Math.LOG2E as a precomputed constant for converting natural log values to base-2 logarithms.

Math.LOG2E

Multiply Math.log(n) by Math.LOG2E to convert from natural log to logβ‚‚.

Challenge: Use Math.LOG2E to compute base-2 logarithms.

πŸ’‘ Hints (2)
  • β€’ logβ‚‚(n) = Math.log(n) * Math.LOG2E
  • β€’ This is equivalent to Math.log(n) / Math.LN2.