相关疑难解决方法(0)

C:使用无符号操作数的一元减运算符行为

我似乎无法在C标准中找到完全定义带有无符号操作数的一元减运算符的行为的相关部分.

2003 C++标准(是的,C++,我用几行代表)在5.3.1c7中说: The negative of an unsigned quantity is computed by subtracting its value from 2^n, where n is the number of bits in the promoted operand.

然而,1999 C标准并未包含这样一个明确的陈述,也没有明确界定一元行为 - 在6.5.3.3c1,3和6.5c4中都没有.在后者中它说Some operators (the unary operator ~, and the binary operators <<, >>, &, ^, and |, ...) ... return values that depend on the internal representations of integers, and have implementation-defined and undefined aspects for signed types.),它排除了一元减去,事情似乎仍然含糊不清.

这个早期的问题是指K&R ANSI C一书中的A.7.4.5节The negative of an unsigned quantity …

c unary-operator

33
推荐指数
3
解决办法
1万
查看次数

标签 统计

c ×1

unary-operator ×1