不使用除法运算符将数字除以5 [英] Divide a number by 5 without using division operator
问题描述
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 %.
推荐答案
我似乎已经从此链接中找到一条出路,这似乎为我的问题提供了答案. http://codegambler.wordpress.com /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. http://codegambler.wordpress.com/2009/08/11/division-operation-without-using-division-operator/
这篇关于不使用除法运算符将数字除以5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!