我有这个代码:
int a = 3, b = 2;
(a/b) << 3 ;
a/b
将如何移动?我如何用二进制表示分数?
最佳答案
(a/b) 不会移动。 它会评估表达式 (a/b) int/int 可能是一个 int,然后它会被移动。
(a/b) << 3
(3/2) << 3 //integer divided by an integer will gives you an integer, So you will get 1
(1) << 3 // 1 will get left shifted with 3 bits
8
关于c - c 中的分数移位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26728513/