Java-based binaries

Source: Internet
Author: User

/*
Different binary data performance:
Binary: Consists of 0, 1. Start with 0b.
Octal: by 0,1,... 7 composition. Start with 0.
Decimal: By 0,1,... 9 composition. The default integer is decimal.
Hex: by 0,1,... 9,a,b,c,d,e,f (both uppercase and lowercase) are composed. Start with 0x.
*/
Class Jinzhidemo {
public static void Main (string[] args) {
SYSTEM.OUT.PRINTLN (100); Decimal

System.out.println (0b100); Binary
System.out.println (0100); Octal
System.out.println (0x100); Hexadecimal
}

}





1: Get the decimal value of the following data:
0b10101
=1*2^4 + 1*2^2 + 1*2^0
=16 + 4 + 1
=21


0123
=1*8^2 + 2*8^1 + 3*8^0
=64 + 16 + 3
=83
0x3c
=3*16^1 + c*16^0
=48 + 12
=60

2: Binary, decimal, hexadecimal for the data below
52 respectively get binary, decimal, hexadecimal


Get binary:
52/2 = 26 0
26/2 = 13 0
13/2 = 6 1
6/2 = 3 0
3/2 = 1 1
1/2 = 0 1

0b110100

Get octal:
52/8 = 6 4
6/8 = 0 6

064

Get 16 binary:
52/16 = 3 4
3/16 = 03

0x34

3: Practice of symbolic data representation
A: It is known that a number of X's original code is 10110100B, try to find X's complement and anti-code.

Sign bit Value bit

Original code: 10110100

Anti-code: 11001011

Complement: 11001100

B: A number of X's complement 11101110B is known, try to find its original code.

Sign bit Value bit

Complement: 11101110

Anti-code: 11101101

Original code: 10010010

4:

Java-based binaries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.