bit shift multiplication in c not using powers of 2 [duplicate]
问题 This question already has answers here : How can I multiply and divide using only bit shifting and adding? (13 answers) Closed 6 years ago . How can I perform multiplication by 36 using bit-shifting? Isn't it only possible to multiply by powers of 2? For example: unsigned x = 4; // binary 00000000 00000000 00000000 00001000 unsigned y = x << 3; // multiply by 8, resulting in binary 00000000 ... 00100000 Thanks! 回答1: You can't multiply by a non-power of 2 by bit shifting alone. But you can