2013-03-04 65 views
0

當我這樣做:JavaScript腳本INT

parseInt(39,16) 

我得到這個:

57 

什麼是第二個參數是指?

我這樣說的:

radix Optional. A number (from 2 to 36) that represents the numeral system to be used 

但是我用16號得到什麼?

+0

您只需在前面加上'+'=>'+ '39' = 39' – elclanrs 2013-03-04 07:28:21

回答

2

第二個參數是你使用的數字系統 - 你的情況「39」是十六進制的,因爲你通過了「16」作爲第二個參數。

refer to the documentation

所以,如果你想獲得的十進制數,使用:

parseInt(39, 10); 
0

例如,基數爲10表示從十進制數,8個八進制數,16個十六進制數等轉換。對於10以上的基數,字母表中的字母表示數字大於9.例如,對於十六進制數字(基數爲16),使用A到F.

ParseInt documentation