负数浮点减法电路
可能问错地方了,但我会尝试。
我必须设计一个可以加/减浮点的电路 我尝试使用 IEE 754 标准中的带符号震级数字来完成此操作。 它们很大,所以我决定从更小的东西开始,只是为了证明这个概念。
我在网上找到了一些用于执行正数加法和减法的算法。
大多数看起来像这样: http://meseec.ce.rit.edu/eecc250 -winter99/250-1-27-2000.pdf 。
他们没有解释符号位会发生什么。 现在我很困惑。根据我在网上发现的内容,执行上没有区别:
A-B and A- (-B)
有人可以帮助我提供详细解释该算法的链接吗?
感谢您的所有回答 我发现这个代数解释很有用 http://howardhuang.us/teaching/cs231/08 -Subtraction.pdf
目前我的电路执行 A+B(忽略符号位)和 AB,就像 kfmfe04 写的那样。我对 B 的输入进行异或并加 1,这样我就得到了 2C 中的结果。
第二个 pdf 建议在加/减操作中包含符号位。我早上会试试这个。
花了这么多时间锻炼我的大脑,我感觉有点累,无法正常思考。现在我只是想知道我是否应该改变我的电路,以便:
切换添加/子按钮仍然对 B [a+(-b)] 进行异或,但在这部分之前,我对尾数'与其符号进行异或,将它们转换为2c.
这样我就可以涵盖负数减法 (-A)-(-B) 的情况。
不过听起来很复杂。
probably wrong place to ask but I will try.
I have to design a circuit that would add/subtract floating point
I tried to do it using signed magnitude numbers in IEE 754 standard.
They are quite large so I decided to start with something smaller just to prove the concept.
I found a few algorithms on the net for performing addition and substraction of positive numbers.
Most look like this:
http://meseec.ce.rit.edu/eecc250-winter99/250-1-27-2000.pdf
.
They do not explain what happens with the sign bit.
Now I'm very confused. According to what I've found on the net there is no difference in performing:
A-B and A- (-B)
could someone help me with a link where the algorithm is explained in detail?
thanks for all answers
I've found this algebraic explanation useful http://howardhuang.us/teaching/cs231/08-Subtraction.pdf
Currently my circuit performs A+B (disregarding sign bit) and A-B just like kfmfe04 wrote. I'm XORing B's input and adding 1 so I getting the result in 2C.
The second pdf suggests including the sign bit in add/sub operation. I will try this in the morning.
Having spent so many hours exercising my brain I feel a bit tired and can't think straight. Now I just wonder if I should change my circuit so that:
The toggle add/sub button still XORs the B [a+(-b)] but also before this part I XORs the mantissas' with their sign to convert them into 2c.
This way I could cover the case of negative numbers subtraction (-A)-(-B).
Sounds to complicated though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本原则是,在内部有一个加法和一个减法部分。这两个例程仅适用于正数。
下面,
ADD
和SUB
用于表示内部例程。您必须根据操作数是正数还是负数将运算分为不同的情况:对于加法:
对于减法:
当然,您也可以简单地将“A - B”定义为“A + -B”,并且只实现添加的情况。
The basic principle is that, internally, you have an addition and a subtraction part. Both routines only work on positive numbers.
Below,
ADD
andSUB
are used to denote the internal routines. You have to divide the operation into different cases, depending on if the operands are positive or negative:For addition:
For subtraction:
Of course, you could also simply define "A - B" as "A + -B" and only implement the cases for addition.