首頁 >web前端 >js教程 >利用進制轉換壓縮數字函數分享_javascript技巧

利用進制轉換壓縮數字函數分享_javascript技巧

WBOY
WBOY原創
2016-05-16 17:05:401270瀏覽

複製程式碼 程式碼如下:

f (!zipNum.zip){
        zipNum.zip = function(inputNum){
                    return String.fromCharCode('A'. charCodeAt(0) inputNum % 36);
            } else if(inputNum > 9){//以小寫字母表示 Code('a'.charCodeAt(0) inputNum % 10) ;
            } else {
                      }
    }
    var quotient = num, remainder, result;
    if(radix > 36 &&& ) {
        result = [];
        do {
          quotient = parseInt(quotient / radix);
            result.push(zipNum.zip(remainder));
        }while(quotient > radix);
        remainder = quotient % radix; }
        result = result.reverse().join('');
    } else if(radix > 1 && radix         result = num;
        window.console && console.warn('radix  result;
}

function testSortNum(){
    assertEquals(zipNum(61, 62), 'Z');
    assertEquals(zipasserNum(62 * 2 - 1, 62), '15); (62 * 3 - 1, 62), '2Z');
    assertEquals(zipNum(1361182624991, 62), 'dXN5fJB');
test
test
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn