Where can I find soft-multiply and divide algorithms?

前端 未结 7 1980
萌比男神i
萌比男神i 2021-02-19 09:00

I\'m working on a micro-controller without hardware multiply and divide. I need to cook up software algorithms for these basic operations that are a nice balance of compact siz

7条回答
  •  清歌不尽
    2021-02-19 09:48

    Here's a division algorithm: http://www.prasannatech.net/2009/01/division-without-division-operator_24.html

    I assume we're talking about ints?

    If there's no hardware support, you'll have to implement your own divide-by-zero exception.

    (I didn't have much luck quickly finding a multiplication algorithm, but I'll keep looking if someone else doesn't find one).

提交回复
热议问题