gpt4 book ai didi

c - "producing negative zeroes"在不支持的系统中是什么意思?

转载 作者:太空狗 更新时间:2023-10-29 16:28:38 25 4
gpt4 key购买 nike

C17 6.2.6.2/4 说:

If the implementation does not support negative zeros, the behavior of the &, |, ^, ~, <<, and >> operators with operands that would produce such a value is undefined.

如果我有一个 2 的补码系统,它不支持负零。它总是利用二进制数的所有可能组合来表示一个值。因此,无论使用哪种按位运算,都不可能产生负零。那么这段文字是什么意思呢?

我的看法是,这部分指的是具有不支持负零的 1 的补码或带符号幅度的系统,而是使用填充位或陷阱表示。这是正确的吗?

最佳答案

是的,我认为你的解释是正确的。在二进制补码中,没有可以生成负零的操作,因为这里的概念不存在:设置了符号位的任何值都必然小于 0

顺便说一句:奇异的符号表示很可能会从 C2x 中删除,因此所有这些都会消失。

关于c - "producing negative zeroes"在不支持的系统中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55044324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com