pow() 方法可返回 x 的 y 次冪的值。
Math.pow(x,y)
參數(shù) | 描述 |
---|---|
x | 必需。底數(shù)。必須是數(shù)字。 |
y | 必需。冪數(shù)。必須是數(shù)字。 |
x 的 y 次冪。
如果結果是虛數(shù)或負數(shù),則該方法將返回 NaN。如果由于指數(shù)過大而引起浮點溢出,則該方法將返回 Infinity。
在下面的例子中,我們將把 pow() 運用到不同的數(shù)字組合上:
<script type="text/javascript"> document.write(Math.pow(0,0) + "<br />") document.write(Math.pow(0,1) + "<br />") document.write(Math.pow(1,1) + "<br />") document.write(Math.pow(1,10) + "<br />") document.write(Math.pow(2,3) + "<br />") document.write(Math.pow(-2,3) + "<br />") document.write(Math.pow(2,4) + "<br />") document.write(Math.pow(-2,4) + "<br />") </script>
輸出:
1 0 1 1 8 -8 16 16
如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網友會為你解答??! 點擊進入論壇
Powered by 365建站網 RSS地圖 HTML地圖
copyright © 2013-2024 版權所有 鄂ICP備17013400號