คุณสมบัติ Math.LN2 แทนค่า ลอการิทึมธรรมชาติของ 2 (ln 2 ≈ 0.6931471805599453)
ไวยากรณ์
Math.LN2
ตัวอย่าง
<html> <head> <title>JavaScript Example</title> </head> <body> <script type="text/javascript"> var data = Math.LN2; document.write(data); </script> </body> </html>
ผลลัพธ์
0.6931471805599453
ความสัมพันธ์:
Math.LN2 = Math.log(2)Math.LOG2E = 1 / Math.LN2- ใช้ในการคำนวณ Half-life, Doubling time, Entropy
การประยุกต์ใช้:
// Half-life calculation const halfLife = Math.LN2 / decayConstant; // Doubling time const doublingTime = Math.LN2 / growthRate; // Binary entropy const entropy = -p * Math.log2(p) - (1-p) * Math.log2(1-p);