re implement modulo using bit shifts?

后端 未结 5 1541
情歌与酒
情歌与酒 2021-02-07 16:10

I\'m writing some code for a very limited system where the mod operator is very slow. In my code a modulo needs to be used about 180 times per second and I figured that removing

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-07 16:48

    If you want to do modulo 10 and shifts, maybe you can adapt double dabble algorithm to your needs?

    This algorithm is used to convert binary numbers to decimal without using modulo or division.

提交回复
热议问题