复制代码 代码如下:
function zipNum(num, radix){
if(!zipNum.zip){
zipNum.zip = function(inputNum){
if(inputNum > 35){//用大写字母表示36-61
return String.fromCharCode('A'.charCodeAt(0) + inputNum % 36);
} else if(inputNum > 9){//用小写字母表示10-35
return String.fromCharCode('a'.charCodeAt(0) + inputNum % 10);
} else {
return inputNum;
}
}
}
var quotient = num, remainder, result;
if(radix > 36 && radix < 63){
result = [];
do {
remainder = quotient % radix;
quotient = parseInt(quotient / radix);
result.push(zipNum.zip(remainder));
}while(quotient > radix);
remainder = quotient % radix;
if(remainder !== 0){
result.push(zipNum.zip(remainder));
}
result = result.reverse().join('');
} else if(radix > 1 && radix < 36){
result = num.toString(radix);
} else {
result = num;
window.console && console.warn('radix argument must be between 2 and 62')
}
return result;
}
function testSortNum(){
assertEquals(zipNum(61, 62), 'Z');
assertEquals(zipNum(62 * 2 - 1, 62), '1Z');
assertEquals(zipNum(62 * 3 - 1, 62), '2Z');
assertEquals(zipNum(1361182624991, 62), 'dXN5fJB');
}
testSortNum();
进制转换,压缩数字
更新动态
- 陈洁仪.1994-心痛【立得唱片】【WAV+CUE】
- 车载必备专用超级选曲《劲爆中文DJ》2CD[WAV+CUE]
- 群星《民歌流淌60年(黑胶CD)》2CD[WAV+分轨]
- 群星《美丽时光》紫银合金AQCD[WAV+CUE]
- 群星《12大巨星畅销精选集》[WAV分轨][1.1G]
- 华语排行冠军曲《百事音乐风云榜》[WAV+CUE][1G]
- 奔驰汽车音乐圣经《醇声典范[白金嗓子] 男极声》音乐传真[WAV+CUE][1G]
- 陈影《如影随形HQ》头版限量[低速原抓WAV+CUE]
- 黄乙玲1996-心痛酒来洗[台湾首版][WAV+CUE]
- 曾庆瑜1990-随风而逝[日本东芝1A1首版][WAV+CUE]
- 群星.2015-凭着爱ADMS2CD【华纳】【WAV+CUE】
- 陈冠希.2017-一只猴子3部曲【摩登天空】【WAV+CUE】
- 金元萱.1996-迷迷糊糊【宝丽金】【WAV+CUE】
- 齐秦《燃烧爱情》马来西亚版[WAV+CUE][1G]
- 动力火车《结伴》2024最新 [FLAC分轨][1G]