R中的等价bitget函数
R中是否有函数执行与MatLab/Octave中的bitget相同的操作:R中的等价bitget函数,r,R,R中是否有函数执行与MatLab/Octave中的bitget相同的操作: 从bitget帮助页面 Return the status of bit(s) n of unsigned integers in A the lowest significant bit is n = 1. bitget (100, 8:-1:1) ⇒ 0 1 1 0 0 1 0 0 因此,如果您想获得R中整数的位值,可以这样做 intToBits(100)[8:1] # [1] 0
从
bitget
帮助页面
Return the status of bit(s) n of unsigned integers in A the
lowest significant bit is n = 1.
bitget (100, 8:-1:1)
⇒ 0 1 1 0 0 1 0 0
因此,如果您想获得R中整数的位值,可以这样做
intToBits(100)[8:1]
# [1] 00 01 01 00 00 01 00 00
从技术上讲,它返回一个原始向量,所以如果您只需要一个数字向量,请
as.numeric(intToBits(100)[8:1])
# [1] 0 1 1 0 0 1 0 0
快速提问,上述问题中函数的结果与八度音程等价的bitget(100,1:30)不匹配,我看到了。它正好相反。