当前位置:网站首页>(二)进制
(二)进制
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 testing department of the company came to the king of the Post-00 roll, and the veteran exclaimed that it was really dry, but
- What are the strengths of "testers"?
- Solve the problem that pycharm Chinese input method does not follow
- Qt:qss custom qheaderview instance
- 2022 pinduogai 100000 sales tutorial
- 最高月薪18K 拥有好的“心态和选择”, 成功就差“认真和坚持”~
- Snownlp emotion analysis
- Day 7 small exercise
- QT:QSS自定义QLineEdit实例
- ByteDance layoffs, test engineers were almost destroyed: how terrible is the routine behind the recruitment of large factories?
猜你喜欢
测试理论概述
EPS电动转向系统分析
Redis notes 01: Introduction
现在零基础转行软件测试还OK吗?
软件测试工程师的5年之痒,讲述两年突破瓶颈经验
月薪过万的测试员,是一种什么样的生活状态?
Cache routing component
. Net core - a queuing system for wechat official account
The highest monthly salary of 18K has a good "mentality and choice", and success is poor "seriousness and persistence"~
.Net Core-做一个微信公众号的排队系统
随机推荐
ExecutorException: Statement returned more than one row, where no more than one was expected.
T5 attempt
测试Leader应该做哪些事
IIS does not take effect after modifying the configuration information
“测试人”,有哪些厉害之处?
QT:QSS自定义QMenu实例
IIS修改配置信息后不生效
Qt:qss custom QSlider instance
Qt:qss custom qmenu instance
How does MySQL find the latest data row that meets the conditions?
Solve the problem that pycharm Chinese input method does not follow
Strategic management of project organization
How to monitor the incoming and outgoing traffic of the server host?
嵌入式软件测试怎么实现自动化测试?
Solution: jupyter notebook does not pop up the default browser
The five-year itch of software testing engineers tells the experience of breaking through bottlenecks for two years
Qt:qss custom qpprogressbar instance
How to realize automatic testing in embedded software testing?
MySQL -- index principle + how to use
那些一门心思研究自动化测试的人,后来怎样了?