当前位置:网站首页>(二)进制
(二)进制
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
![]()
边栏推荐
- The element form shows the relationship between elementary transformation and elementary matrix
- “测试人”,有哪些厉害之处?
- Internet Socket (非)阻塞write/read n个字节
- MySQL -- index principle + how to use
- Basic usage of sqlmap
- .Net Core-做一个微信公众号的排队系统
- Solve the problem that pycharm Chinese input method does not follow
- 嵌入式軟件測試怎麼實現自動化測試?
- Qt:qss custom qmenu instance
- 8年测试工程师总结出来的《测试核心价值》与《0基础转行软件测试超全学习指南》
猜你喜欢
现在零基础转行软件测试还OK吗?
Tencent micro app to get wechat user information
嵌入式軟件測試怎麼實現自動化測試?
What happened to those who focused on automated testing?
Cause: org. apache. ibatis. builder. Builderexception: error parsing SQL mapper configuration problem analysis
Interviewer: what is the internal implementation of the list in redis?
反正切熵(Arctangent entropy):2022.7月最新SCI论文
字节跳动大裁员,测试工程师差点遭团灭:大厂招人背后的套路,有多可怕?
Lecture 1 number field
How to realize automatic testing in embedded software testing?
随机推荐
What happened to those who focused on automated testing?
Typescript learning summary
Programming examples of stm32f1 and stm32subeide -tm1637 drives 4-bit 7-segment nixie tubes
My understanding of testing (summarized by senior testers)
Definition and properties of summation symbols
How can UI automated testing get out of trouble? How to embody the value?
Flink < --> how to use redis +with parameter
最高月薪18K 拥有好的“心态和选择”, 成功就差“认真和坚持”~
Rollup, cube and grouping sets functions of grouping functions
Qt:qss custom qmenubar instance
sqlmap基本使用方法
15 software testing Trends Worthy of attention
Qt:qss custom qscrollbar instance
Qt:qss custom qheaderview instance
[proteus simulation] 16 channel water lamp composed of 74hc154 four wire to 12 wire decoder
ByteDance layoffs, test engineers were almost destroyed: how terrible is the routine behind the recruitment of large factories?
8年测试总监的行业思考,看完后测试思维认知更深刻
QT: QSS custom qtoolbar and qtoolbox instances
测试Leader应该做哪些事
【Proteus仿真】74HC154 四线转12线译码器组成的16路流水灯