简体   繁体   English

执行以下1的补码定点integer算术运算

[英]Perform the following 1's complement fixed-point integer arithmetic operations

This question is from my digital logic class but I don't understand it.这道题出自我的数字逻辑class 但是我没看懂。 Please help me understand what it is asking me.请帮助我理解它在问我什么。

Lets say A1 and A2 are octal shorthand.假设 A1 和 A2 是八进制速记。

Perform the following 1's complement fixed-point integer arithmetic operations and note whether magnitude overflow has occurred in each case: (Hint: Use 7's complement arithmetic on the other octal shorthand),执行以下1的补码定点integer算术运算,并注意在每种情况下是否发生量级溢出:(提示:在另一个八进制速记上使用7的补码算法),

i) A3= A1+A2
ii) A3= A1-A2

I thought you only take complements when you want to do subtraction.我以为你只在你想做减法的时候才取补码。 Can't I just do the subtraction in octal form?我不能只做八进制形式的减法吗? Can someone help me understand what the questions are ask?有人可以帮助我理解所问的问题吗?

I'm not sure how the obscure "octal short-hand"/"7s-complement" comes into play, but here is the "traditional" solution:我不确定晦涩的“八进制速记”/“7s-补码”是如何发挥作用的,但这是“传统”解决方案:

i) A3 = A1+A2
       1
       2631
       84268421
       01000000
    A1=10100001 = -94
  + A2=10100010 = -93
    ------------
    A3=01000011 = -187 < -127 so we know this is wrong 
co:    10100000

  CO = 1 which also indicates result is wrong


ii) A3 = A1-A2
        1000000
    A1=10100001 = -33
  - A2=10100010 = -34
    ------------
    A3=????????? =  1  < 127 so we know this is right
  ==
        0000010
    A1=10100001
  + A2=01011101
    ------------
    A3=11111110 = -67
co:    00000001 = 1

  CO = 0 which also indicates result is right

It's a trick question; 这是一个棘手的问题。 or you misquoted it. 否则您会错误地引用它。 I doubt your instructor would ask the former; 我怀疑你的教练会问前者; so it must be the latter. 所以一定是后者。

Recall that a 1s complement sum is the XOR of two operands (here A1 and A2). 回想一下1s的补码和是两个操作数(此处为A1和A2)的XOR。 And that there is no carry and therefore no such thing as magnitude overflow in the 1s complement world. 而且没有进位,因此在1s补码世界中没有幅度溢出这样的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM