/** * 十进制转换为2~36的任意进制 */
const baseConverter = (number = 12138, base = 2) => { const stack = [] const digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; let baseStr = '' if(!(base >= 2 && base <= 36))return let rem = 0 while(number > 0){ rem = Math.floor(number % base) stack.push(rem) number = Math.floor(number / base) } while(stack.length){ baseStr += digits[stack.pop()] } return baseStr }
标签:const,进制,number,36,base,baseStr,十进制,stack From: https://www.cnblogs.com/zhenjianyu/p/17072552.html