javascript 位数组https://github.com/owocki/Interview_prep_checklist#some-bit-hacks
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 位数组https://github.com/owocki/Interview_prep_checklist#some-bit-hacks相关的知识,希望对你有一定的参考价值。
const isEven = num => ((num & 1) == 0)
const isNthBit = (num, n) => (num & (1 << n))
const setNthBit = (num, n) => (num | (1 << n))
const unsetNthBit = (num, n) => (num & ~(1 << n))
const toggleNthBit = (num, n) => (num ^ (1 << n))
const findRightmost1Bit = num => (num & (-num))
const unsetRightmost1Bit = num => (num & (num - 1))
const asBitArrayString = num => num.toString(2)
const asBitArrayNumber = str => parseInt(str, 2)
以上是关于javascript 位数组https://github.com/owocki/Interview_prep_checklist#some-bit-hacks的主要内容,如果未能解决你的问题,请参考以下文章
javascript 位数组https://github.com/owocki/Interview_prep_checklist#some-bit-hacks
React开发(149):二位数组的使用
Git安装及知识点
某一组数据的中位数怎么计算
怎样找到一组数据的中位数?
二位数组传参及二位数组动态分配问题