当前位置:网站首页>Binary computing
Binary computing
2022-06-24 15:34:00 【HLee】
brief introduction
Binary is a number system widely used in computing technology . Binary data is used 0 and 1 A number represented by two numbers . Its cardinality is 2, The carry rule is “ On the two into one ”, The rule of borrowing is “ Borrow one for two ”, from 18 Leibniz, a German master of mathematical philosophy in the th century, found that . The current computer system is basically a binary system , Data is mainly stored in the form of complement in the computer . Because the logic of the circuit is only 0 and 1 Two states , there 0 and 1 It's not numerical 0 and 1,0 and 1 It means two different states ,0 Indicates low level ,1 High level . A computer is made up of innumerable logic circuits , adopt 0 and 1 The infinite number of bits and combinations to express information .
Java Built in conversion
stay Java There are several built-in methods to help us carry out various decimal conversions . As shown in the figure below ( With Integer Plastic surgery, for example ):
Binary system :Integer.toBinaryString(int i) octal :Integer.toOctalString(int i) Octagon :Integer.toHexString(int i)
Binary to decimal :
Integer.valueOf("0101",2)
Integer.parseInt("11", 2)
octal :Integer.valueOf("376",8)
Hexadecimal :Integer.valueOf("FFFF",16)Use Integer Class parseInt() Methods and valueOf() Methods can convert other base numbers to 10 Base number .
System.out.println("int Maximum positive number :" + Integer.MAX_VALUE);
System.out.println("int The maximum positive binary representation :" + Integer.toBinaryString(Integer.MAX_VALUE));
System.out.println("int Minimum negative number :" + Integer.MIN_VALUE);
System.out.println("int The minimum negative number is binary :" + Integer.toBinaryString(Integer.MIN_VALUE));
System.out.println(" Binary definition printing int The maximum number that can be represented :" + 0b01111111_11111111_11111111_11111111);
System.out.println(" Binary definition printing int The smallest number that can be expressed :" + 0b10000000_00000000_00000000_00000000);
System.out.println("43 Binary representation of :" + Integer.toBinaryString(43));// The result omits the previous 0
System.out.println("-43 Binary representation of :" + Integer.toBinaryString(-43));
// Underline is meaningless , Just for convenience , Can write at will
int a = 0b00000000_00000000_00000000_00000000_00101011;//0b Represented as binary ,a The decimal equivalent of 43
int a1 = 0b101011;// It's also decimal 43, Just omit the above 0
System.out.println(" Print a Value :" + a);
System.out.println(" Print a1 Value :" + a1);
int b = 0b11111111_11111111_111111111_1010101;// Binary system 43 Add... In reverse 1, become -43, Underline is meaningless
System.out.println(" Print b Value :" + b);
int i = 0b00000001_00110010_01100111_10101101;// I wrote a decimal 24274861
System.out.println(" Print 10 It's binary i:" + i);
System.out.println(" Print is forced to short Of i:" + (short)i);
System.out.println(" Print short The binary representation of :" + Integer.toBinaryString((short)i));
result :
int Maximum positive number :2147483647
int The maximum positive binary representation :1111111111111111111111111111111
int Minimum negative number :-2147483648
int The minimum negative number is binary :10000000000000000000000000000000
Binary definition printing int The maximum number that can be represented :2147483647
Binary definition printing int The smallest number that can be expressed :-2147483648
43 Binary representation of :101011
-43 Binary representation of :11111111111111111111111111010101
Print a Value :43
Print a1 Value :43
Print b Value :-43
Print 10 It's binary i:20080557
Print is forced to short Of i:26541
Print short The binary representation of :110011110101101int To short when , Direct interception status 16 Bit conversion
边栏推荐
- Py's toad: a detailed introduction to toad, its installation and use
- 个人如何开户炒股 炒股开户安全吗
- How to allow easydss online classroom system to upload an on-demand file with a space in the file name?
- Bert whitening vector dimension reduction and its application
- update+catroot+c000021a+critical service failed+drivers+intelide+viaide+000000f
- Laravel8 uses faker to call factory to fill data
- QTreeWidget作为单例模式以dll返回的两个问题
- 设备通过国标GB28181接入EasyCVR平台,出现断流情况该如何解决?
- ES mapping之keyword;term查詢添加keyword查詢;更改mapping keyword類型
- A common defect management tool - Zen, which teaches you from installation to using the handle
猜你喜欢
An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!

动作捕捉系统用于地下隧道移动机器人定位与建图

From pair to unordered_ Map, theory +leetcode topic practice

Multimeter resistance measurement diagram and precautions

常见的缺陷管理工具——禅道,从安装到使用手把手教会你

CVPR 2022 - Interpretation of selected papers of meituan technical team

Do you really know the difference between H5 and applet?

Data sharing between laravel lower views

Wide measuring range of jishili electrometer

How to generate assembly code using clang in Intel syntax- How to generate assembly code with clang in Intel syntax?
随机推荐
刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪
同样是初级测试工程师,为啥他薪资高?会这几点面试必定出彩
Restoring to an earlier version in CVS
缓存使用中Redis,Memcached的共性和差异分析
Analysis of similarities and differences between redis and memcached in cache use
openinstall携手书链:助力渠道数据分析,共创书联网时代
Allwinner a40i industrial Internet gateway design scheme, smart site, smart city core gateway
An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!
[sdx62] wcn685x IPA registration failure analysis and solution
CVPR 2022 - Interpretation of selected papers of meituan technical team
Redis consistency hash and hash slot
Oracle RAC configuration multipathing
update+catroot+c000021a+critical service failed+drivers+intelide+viaide+000000f
Which securities company is better and safer for great wisdom to choose when opening an account
[parameter configuration tutorial] how should the parameters in the RTMP streaming camera be configured?
[log service CLS] a taste of Tencent cloud log service CLS
The industrial control security of roaming the Intranet
A common defect management tool - Zen, which teaches you from installation to using the handle
MySQL replication series 6- tables related to replication information
测试 H5 和小程序的区别,你真的知道吗?