简单粗暴的方法,转换为二进制,变为字符串,转成数组,反转,取值
function valueAtBit (num, bit) {
let two = num.toString(2) + ''
let res = two.split('').reverse()
return res[bit-1]
}
简单粗暴的方法,转换为二进制,变为字符串,转成数组,反转,取值
function valueAtBit (num, bit) {
let two = num.toString(2) + ''
let res = two.split('').reverse()
return res[bit-1]
}