c - 这学期刚开始学C,但我似乎无法理解教授在这道题中想从我们这里得到什么

标签 c twos-complement ones-complement

原始问题:

A positive number has the same representation in one’s complement and in two’s complement. Suppose its representation is interpreted as two’s complement, and its additive inverse is determined. Now this representation is interpreted as one’s complement, and the additive inverse is determined. Whether interpreted as one’s complement or two’s complement, the result will be the same, since it is a positive number. What is the relationship between this result and the original number?

我不知道他所说的“这个结果和原始数字之间有什么关系”是什么意思。我想我明白他要我们做的事情的流程:

首先取二进制 (0101),然后取二进制补码 (1011),然后取二进制补码的补码 (0100)。接下来怎么办?

最佳答案

如果我发布的内容不止于此,我会给你答案......

结果数字不会与原始数字相同,但无论选择哪个值作为原始数字,它们之间的差异都是一致的。通过几个例子,直到你明白其中的关系。您已经展示了一个二进制示例,这可能会使您更难以看出其中的关系。以十进制格式完成几个示例(如果有帮助,请转换为二进制,然后再转换回十进制)。选择以偶数开头的示例和以奇数开头的其他示例,这样您就不会得出有关关系的错误结论。

然后,作为奖励,看看你是否能找出这种关系存在的原因。它与以下事实有关:一种格式的值的求反与另一种格式的值的求反的执行方式不同。

关于c - 这学期刚开始学C,但我似乎无法理解教授在这道题中想从我们这里得到什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60266386/

相关文章:

c - 当分辨率高于 320 像素时,Mandelbrot 代码不令人兴奋?

c++ - a+(-a) 操作期间溢出

c++ - 在计算负数的二进制补码时如何实现添加 "+1"步骤

python - 在 Python 中从十六进制到一个补码

c - 这段代码在 C 中意味着什么, "int x = ~!printf; "?

c - 严格的别名和内存位置

无法比较 token

将一串十六进制数字转换为整数

手动二进制 2 的补码乘法?

c++ - -1 和 ~0 有什么区别