可能重复: 使用按位运算符的实现划分 将数字除以3而不使用*,/,+,-,%运算符
Possible Duplicate: implement division with bit wise operator Divide a number by 3 without using *, /, +, -, % operators
我在一次采访中遇到了这个问题.我想知道是否存在不使用除法运算符将数字除以5的任何可能的方法,以及是否仅使用按位运算符存在任何可能的解决方案.我想出了使用重复减法直到零逼近的方法.数字可以签名也可以不签名. 请提出任何解决方法,而不使用+,-,/,*和%.
I came across this question in an interview. I want to know if there any possibly way to divide a number by 5 without using division operator and if any possible solution exists using bitwise operators only.I figured one out using repeated subtraction till zero approaches. Number can be signed and unsigned. Please suggest any way out without using +,-,/,* and %.
推荐答案我似乎已经从此链接中找到一条出路,这似乎为我的问题提供了答案. codegambler.wordpress /2009/08/11/division-operation-without-using-division-operator/
I seem to have found a way out from this link which seems to provide an answer to my question. codegambler.wordpress/2009/08/11/division-operation-without-using-division-operator/