110.for循环执行顺序
for(clogb2=0; bit_depth>0; clogb2=clogb2+1) bit_depth = bit_depth >> 1;
这个是先执行clogb2=clogb2+1一次它再执行 bit_depth = bit_depth >> 1;
还是先执行完bit_depth = bit_depth >> 1;再执行clogb2=clogb2+1
循环次数 | 执行前 clogb2 | 检查条件 bit_depth>0 | 执行循环体 bit_depth >> 1 | 执行后 bit_depth | 执行迭代 clogb2+1 | 执行后 clogb2 |
---|---|---|---|---|---|---|
1 | 0 (初始) | 7>0 → 真 | 7 >> 1 = 3 | 3 | 0+1=1 | 1 |
2 | 1 | 3>0 → 真 | 3 >> 1 = 1 | 1 | 1+1=2 | 2 |
3 | 2 | 1>0 → 真 | 1 >> 1 = 0 | 0 | 2+1=3 | 3 |
4 | 3 | 0>0 → 假 | (不执行) | 0 | (不执行) | 3 (最终结果) |