问题描述
我想知道如何在没有除法硬件和浮点硬件的情况下以二进制实现 IEEE-754 32 位单精度浮点除法?
I am wondering how to implement IEEE-754 32-bit single precision floating point division in binary with no division hardware and no floating point hardware?
我有移动硬件、加法、减法和乘法.
I have shifting hardware, add, subtract, and multiply.
我已经使用 16 位字实现了浮点乘法、加法和减法.
I have already implemented floating point multiplication, addition, and subtraction using 16-bit words.
我正在一个专有的多核处理器上实现这些指令,并用汇编语言编写我的代码.之前,我正在使用 matlab 来验证我的算法.
I am implementing these instructions on a proprietary multicore processor and writing my code in assembly. Beforehand, I am using matlab to verify my algorithm.
我知道我需要减去指数,但是如何对尾数执行无符号除法?
I know I need to subtract the exponents, but how do i perform unsigned division on the mantissas?
推荐答案
取决于你想让它变得多复杂.保持相当简单,您可以尝试通过倒数近似除法.
Depends on how complicated you want to make it. Keeping it reasonably simple, you could try division by reciprocal approximation.
而不是计算:(n/d)你会计算:n *(1/d).
Rather than calculating: (n / d) you'd work out: n * (1 / d).
为此,您需要使用某种方法计算倒数,例如 Newton-Raphson,它使用牛顿法连续计算除数倒数的更准确估计,直到它足够"准确地满足您的目的,然后再进行最后的乘法步骤.
To do this you'd need to work out the reciprocal using some method, for example, Newton-Raphson which uses Newton's method to calculate successively more accurate estimates of the reciprocal of the divisor until it's "adequately" accurate for your purpose before doing the final multiplication step.
编辑
刚刚看到你的更新.毕竟这可能对你有用,也可能没用!
Just seen your update. This may, or may not, be useful for you after all!
这篇关于如何在没有除法硬件和没有浮点硬件的二进制中实现浮点除法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!