当前位置:网站首页>单目操作符(含原码反码补码转换)
单目操作符(含原码反码补码转换)
2022-08-10 11:01:00 【51CTO】
单目运算符是指运算所需变量为一个的运算符,即在运算当中只有一个操作数,又叫一元运算符。
~ 例子如下
输出结果为-1
因为b=~a,所以b是有符号的整形(数字好像都是带符号的),所以最高位指的是符号位,1为负,0为正。又因为负数在内存中存储的时候,存储的是二进制的补码。而我们打印/使用的是这个数的原码。
原码,反码,补码的计算规则:
原码到反码:符号位不变,其余取反。
反码到补码:反码+1得到补码。
++ -- 例子如下
总结:不管前置或者后置,a都需要进行加减。但计算b时,若后置,则“后知后觉”,b不变;若前置,则与a相同!
(类型)强制类型转换····不建议 例子如下
边栏推荐
猜你喜欢
GPU accelerated Pinterest recommendation model, the number of parameters increased by 100 times, and the user activity increased by 16%
中小规模网站架构
Pycharm终端出现PS问题、conda或activate不是内部命令问题..
runtime-core.esm-bundler.js?d2dd:218 Uncaught TypeError: formRef.value?.validate is not a function
第2章-矩阵及其运算-矩阵运算(2)
Research on motion capture system for indoor combined positioning technology
[Brave food, not afraid of the linked list of brushing questions] Merging of ordered linked lists
金九银十跳槽旺季:阿里、百度、京东、美团等技术面试题及答案
[Brave food, not afraid to write the linked list] The problem of the penultimate node of the linked list
Store limited time seckill function system
随机推荐
[Go WebSocket] 多房间的聊天室(一)思考篇
Alibaba最新神作!耗时182天肝出来1015页分布式全栈手册太香了
【Untitled】
不止跑路,拯救误操作rm -rf /*的小伙儿
YTU 2894: G--我要去内蒙古大草原
Hangdian Multi-School-Loop-(uncertainty greedy + line segment tree)
3 injured in 'electrical accident' at Google data center
LAXCUS分布式操作系统安全管理
实现内网穿透的最佳解决方案(无实名认证,完全免费)
使用.NET简单实现一个Redis的高性能克隆版(六)
4 of huawei offer levels, incredibly side is easing the bit in the interview ali?
一文带你搞懂中断按键驱动程序之poll机制
Codeforces 814 C. An impassioned circulation of affection (dp)
第5章相似矩阵及二次型(4)
8月份DB-Engines 数据库排行榜最新战况
力扣练习——59 从二叉搜索树到更大和树
金九银十跳槽旺季:阿里、百度、京东、美团等技术面试题及答案
OneFlow source code parsing: operator instructions executed in a virtual machine
rider内Mono脚本找不到引用资源
2022年裁员潮,失业程序员何去何从?