c++ - 我对“计算”无符号字符的未知行为
问题描述
问题在代码中。
#include <iostream>
int main()
{
typedef unsigned char uchar;
uchar u = ~uchar();
// The following line, at least using gcc, prints: -1 �
// The rvalue it's printed as a number, and the lvalue as a character.
// What's the explanation of this behaviour for this particular type?
std::cout << ~uchar() << ' ' << u << std::endl;
return 0;
}
解决方案
推荐阅读
- java - 在多模块项目中覆盖配置文件中的属性在 Maven 中无法正常工作
- r - 表 1 包 R 中的 ANOVA P 值列
- git - 如何在开发分支上重新设置功能分支
- .net-core - 如何让 Alpine Linux 用户向我的应用程序提供他们的 Mutual TLS 证书?
- jenkins - 在 Jenkins 中,Jupyter 内核 python 未与 conda python 对齐
- azure-powershell - 添加-AzureADUser Powershell
- git - Jenkins,使用 withCredentials,我如何使用 SSH 私钥对 Git 进行身份验证?
- assembly - 如果我在 x86 AT&T 语法中省略比例因子和索引寻址模式会发生什么?
- python - 如何编写一个快速的 PyTorch 训练循环?
- postgresql - Bucardo 可以执行更频繁的提交吗?