当前位置:网站首页>(二)进制
(二)进制
2022-07-03 09:47:00 【来世做春风嘛】
一、进制
1.进制介绍
对于整数,有四种表示方式:
(1)二进制:以0b或0B开头
(2)十进制:
(3)八进制:以数字0开头表示。
(4)十六进制:以0x或0X开头表示
2. 二进制转八进制
规则:从低位开始,将二进制数每三位一组,转成对应的八进制数即可
案例:请将0b11010101转成八进制0b110(3)010(2)101(5) = 0325
3. 二进制转十六进制
规则:从低位开始,将二进制数每四位一组,转成对应的十六进制数即可
案例:请将:0b11010101转成十六进制0b1101(13)0101(5) = 0XD5
4. 八进制转二进制
规则:将八进制数每1位,转成对应的一个3位的二进制数即可
案例:请将0237转成二进制02(010)3(011)7(111)= 0B10011111
5. 十六进制转换成二进制
规则:将十六进制数每1位,转成对应的4位的一个二进制数即可。
案例:请将0x23B转成二进制0x2(0010)3(0011)B(1011) = 0B1000111011
P97 晕了
二、原码、反码、补码(重点难点)
对于有符号的而言:
(1)二进制的最高位是符号位:0表示正数,1表示负数
(2)正数的原码,反码,补码都一样(三码合一)
(3)负数的反码 = 它的原码符号位不变,其它位取反(0->1,1->0)
(4)负数的补码 = 它的反码 + 1,负数的反码 = 负数的补码 - 1
(5)0的反码,补码都是0
(6)java 没有无符号数,换言之,java中的数都是有符号的
(7)在计算机运算的时候,都是以补码的方式来运算的
(8)当我们看运算结果的时候,要看他的原码
三、位运算符
java中有7个位运算(& 、| 、^ 、~、 >>、<<和>>>)
分别是 按位与& 、按位或| 、按位异或^ ,按位取反~,它们的运算规则是:
(1)按位与& :两位全为1,结果为1,否则为0
(2)按位或| :两位有一个为1,结果为1,否则为0
(3)按位异或^ :两位一个为0,一个为1,结果为1,否则为0
(4)按位取反~:0->1,1->0
![]()
边栏推荐
猜你喜欢

QT: QSS custom qtabwidget and qtabbar instances

T5 的尝试

Tencent micro app to get wechat user information

使用ML.NET+ONNX预训练模型整活B站经典《华强买瓜》

Lecture 1 number field

可以写进简历的软件测试电商项目,不进来get一下?

你真的需要自动化测试吗?

Qt:qss custom qpprogressbar instance

How to realize automatic testing in embedded software testing?

What are the strengths of "testers"?
随机推荐
程序进程管理工具-go supervisor
Rollup, cube and grouping sets functions of grouping functions
Exclusive analysis | truth about resume and interview
Solve the problem that pycharm Chinese input method does not follow
Is it OK to test the zero basis software?
Snownlp emotion analysis
UI自动化测试如何走出困境?价值又如何体现?
Basic theoretical knowledge of software testing -- app testing
Imread change image display size
做软件测试三年,薪资不到20K,今天,我提出了辞职…
php如何解决高并发问题
T5 的尝试
How does MySQL find the latest data row that meets the conditions?
“测试人”,有哪些厉害之处?
The testing department of the company came to the king of the Post-00 roll, and the veteran exclaimed that it was really dry, but
在职美团测试工程师的这八年,我是如何成长的,愿技术人看完都有收获
First line of code kotlin notes
The solution that prompts "system group policy prohibits the installation of this device" under win10 system (home version has no group policy)
QT:QSS自定义QLineEdit实例
月薪过万的测试员,是一种什么样的生活状态?

