问题标签 [bitwise-not]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
21 问题
0
投票
1
回答
69
浏览
c++ - 为什么在翻转 1 时没有给出意想不到的结果?
我目前正在学习按位运算符的过程,并且遇到了一些我无法弄清楚的事情。
我目前正在使用 NOT(~) 运算符,它应该反转所有位。因此,为了更好地理解它,我尝试创建一个程序来翻转数字 1 的位。
但是,当运行它时,我得到 -2 结果。谁能解释为什么这不起作用?