11
当我测试C中移位和乘法之间的时间差异时,没有差异。为什么?
有人告诉我,二进制移位比乘以2 ^ k要有效得多。因此,我想尝试一下,并使用以下代码对此进行了测试: #include <time.h> #include <stdio.h> int main() { clock_t launch = clock(); int test = 0x01; int runs; //simple loop that oscillates between int 1 and int 2 for (runs = 0; runs < 100000000; runs++) { // I first compiled + ran it a few times with …