Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

คุณสมบัติ Math.LOG2E ใน JavaScript

คุณสมบัติ Math.LOG2E แทนค่า ลอการิทึมฐาน 2 ของ e (log₂e ≈ 1.4426950408889634)

ไวยากรณ์

Math.LOG2E

ตัวอย่าง

<html> <head>    <title>JavaScript Example</title> </head> <body>    <script type="text/javascript">       var result = Math.LOG2E;       document.write(result);    </script> </body> </html>

ผลลัพธ์

1.4426950408889634

ความหมายทางคณิตศาสตร์:

  • LOG2E = log₂(e) = 1 / ln(2)
  • ใช้ในการแปลงฐานลอการิทึม: log₂(x) = ln(x) * LOG2E
  • เกี่ยวข้องกับ Information Theory (Entropy ในหน่วย bits)

ฟังก์ชันที่เกี่ยวข้อง:

  • Math.log2(x) - คำนวณ log₂(x) โดยตรง (ES6+)
  • Math.LN2 - ln(2) ≈ 0.693
  • Math.log(x) - ln(x) (ลอการิทึมธรรมชาติ)