JS中的Math.pow(a,b)方法

來源:互聯網
上載者:User

標籤:color   nbsp   class   浮點   style   組合   rip   pow   返回   

定義和用法pow() 方法可返回 x 的 y 次冪的值。
文法Math.pow(x,y)
參數 描述x 必需。底數。必須是數字。y 必需。冪數。必須是數字。
傳回值x 的 y 次冪。
說明如果結果是虛數或負數,則該方法將返回 NaN。如果由於指數過大而引起浮點溢出,則該方法將返回 Infinity。
執行個體在下面的例子中,我們將把 pow() 運用到不同的數字組合上:
<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>輸出:10118-81616

 

JS中的Math.pow(a,b)方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.