radix 2 º£À̽ºÀÇ ÇØ´ç ¼öÄ¡¸¦ 10Áø¹ý ¼öÄ¡·Î ȯ»êÇÑ´Ù.
2Áø¼ö¸¦ 10Áø¼ö·Î ȯ»êÇÏ´Â °ÍÀ¸·Î 3¹ø¿¡¼ 2Áø¹ý¿¡´Â '0'°ú '1'¸¸ À¯È¿ÇϹǷΠ¾Õ '10'¸¸ ȯ»êÇÏ°Ô µÇ¾î 10Áø¼ö 2°¡ µÈ´Ù.
<SCRIPT> document.write("1) "+parseInt("10",2)); // ÀüºÎ À¯È¿ÇÑ 2Áø¼ö document.write("<BR>2) "+parseInt("1011101",2)); // ÀüºÎ À¯È¿ÇÑ 2Áø¼ö document.write("<BR>3) "+parseInt("102030",2)); // 2, 3Àº 2Áø¼ö¿¡¼ ¹«È¿¼öÄ¡ document.write("<BR>4) "+parseInt("a101010",2)); // a´Â 2Áø¼ö¿¡¼ ¹«È¿¼öÄ¡ // 2Áø¼ö´Â 0, 1, 10, 11, 100, 101, 110, 111,1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000,... </SCRIPT>
<SCRIPT> document.write("1) "+parseInt("0xa",16)); // 0x´Â 16Áø¼öÀÓÀ» Ç¥½ÃÇÏ´Â ±âÈ£ÀÓ, 16Áø¼ö a document.write("<BR>2) "+parseInt("0xff",16)); // 0x´Â 16Áø¼öÀÓÀ» Ç¥½ÃÇÏ´Â ±âÈ£, 16Áø¼ö ff document.write("<BR>3) "+parseInt("20",16)); // 16Áø¼öÀÓÀ» Ç¥½ÃÇÏ´Â ±âÈ£ »ý·« document.write("<BR>4) "+parseInt("g12",16)); // g´Â 16Áø¼ö¿¡¼ ¹«È¿¼öÄ¡ // 16Áø¼ö´Â 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f, 10,...19, 1a,1b, 1c, 1d, 1e, 1f, 20, 21,...2f, 30,.... ff, 100,... </SCRIPT>
parseInt() ÇÑ °á°ú¸¦ ´Ù½Ã isNaN() ±â´ÉÇÔ¼ö·Î Á¡°ËÇÏ¿´´Ù. ³»¿ëÀ» ¹Ù²Ù°í È®ÀÎÇØ º¸¶ó.
À¯È¿¼öÄ¡´Â 2Áø¼ö(0,1); 8Áø¼ö(0~7); 10Áø¼ö(0~9); 16Áø¼ö(0~9,a,b,c,d,e,f,A,B,C,D,E,F)function checkit(obj){ // »ç¿ëÀÚ Á¤ÀÇ ±â´ÉÇÔ¼öÀÇ ½ÃÀÛ var str=''; // Ãâ·Â¿ë ¹®ÀÚ¿ ¼±¾ð var objVal=obj.testString.value; var radix=obj.inradix.value; if ((radix<2)||(radix>32)){ alert('radix´Â 2-32 »çÀÌ À̾î¾ß ÇÔ.'); obj.inradix.focus(); return false; } if (isNaN(parseInt(objVal,radix))){ // ¹«È¿¼öÄ¡À̸é str+='<font color=green>"'+objVal+'"</font>´Â ¼öÄ¡°¡ ¾Æ´Ï´Ù.'; str+="<BR>ù ¹®ÀÚ°¡ <font color=red>"'+objVal.substring(0,1)+'"</font>À̹ǷÎ"; str+='<BR>parseInt("'+objVal+'","'+radix+'") °á°ú´Â <font color=blue>NaN</font>ÀÌ´Ù.'; } else str='parseInt("'+objVal+'","'+radix+'")='+parseInt(objVal,radix); // À¯È¿¼öÄ¡À̸é showArea.innerHTML=str; // id=showArea ³»¿ëÀ» HTML ÅÂ±× º¯°æÇÏ¿© Ãâ·ÂµÇ°Ô ÇÑ´Ù } // »ç¿ëÀÚ Á¤ÀÇ ±â´ÉÇÔ¼öÀÇ Á¾·á </SCRIPT> <DIV id=showArea style="border:solid 1 blue;width:400;height:5em;padding:5" title="°á°ú">°á°ú Ç¥½Ã °³Ã¼</DIV> <FORM name="testForm"> °Ë»ç ¹®ÀÚ¿ : <INPUT type=text name="testString" value="100"> º£À̽º <SPAN class=argument>radix</SPAN> : <INPUT type=text name="inradix" value="10" size=2>(2~32) <INPUT type=button value="È®ÀÎ" onClick="checkit(this.form)"> </FORM>