负数浮点减法电路

发布于 2024-12-23 16:10:49 字数 874 浏览 2 评论 0原文

可能问错地方了,但我会尝试。
我必须设计一个可以加/减浮点的电路 我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫南 2024-12-30 16:10:49

基本原则是,在内部有一个加法和一个减法部分。这两个例程仅适用于正数。

下面,ADDSUB用于表示内部例程。您必须根据操作数是正数还是负数将运算分为不同的情况:

对于加法:

pos1 + pos2 => pos1 ADD pos1
pos1 + neg2 => pos1 SUB abs(neg2)
neg1 + pos2 => pos2 SUB abs(neg1)
neg1 + neg2 => - (abs(neg1) ADD abs(neg2))

对于减法:

pos1 - pos2 => pos1 SUB pos2
pos1 - neg2 => pos1 ADD abs(neg2)
neg1 - pos2 => - (abs(neg1) ADD pos2)
neg1 - neg2 => abs(neg2) SUB abs(neg1)

当然,您也可以简单地将“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 and SUB 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:

pos1 + pos2 => pos1 ADD pos1
pos1 + neg2 => pos1 SUB abs(neg2)
neg1 + pos2 => pos2 SUB abs(neg1)
neg1 + neg2 => - (abs(neg1) ADD abs(neg2))

For subtraction:

pos1 - pos2 => pos1 SUB pos2
pos1 - neg2 => pos1 ADD abs(neg2)
neg1 - pos2 => - (abs(neg1) ADD pos2)
neg1 - neg2 => abs(neg2) SUB abs(neg1)

Of course, you could also simply define "A - B" as "A + -B" and only implement the cases for addition.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文