How can I multiply and divide using only bit shifting and adding?

后端 未结 14 1781
清歌不尽
清歌不尽 2020-11-22 15:09

How can I multiply and divide using only bit shifting and adding?

14条回答
  •  眼角桃花
    2020-11-22 15:27

    it is basically multiplying and dividing with the base power 2

    shift left = x * 2 ^ y

    shift right = x / 2 ^ y

    shl eax,2 = 2 * 2 ^ 2 = 8

    shr eax,3 = 2 / 2 ^ 3 = 1/4

提交回复
热议问题