Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的等价bitget函数_R - Fatal编程技术网

R中的等价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

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] 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)不匹配,我看到了。它正好相反。