Byte data type-java

Source: Internet
Author: User

Byte and character an English letter (not case) occupies a byte of space, a Chinese character occupies two bytes, a binary number sequence, in the computer as a digital unit, generally 8-bit binary number, converted to a decimal minimum value of 0, the maximum value is 255.

UTF-8 code: An English character is a byte, a Chinese character (including traditional characters) is three bytes. Unicode code: An English character is two bytes, and a Chinese character (with traditional characters) equals two bytes. Symbol: English punctuation occupies one byte, Chinese punctuation is two bytes. Different order of magnitude: data storage is represented in 10 notation, and data transfer is expressed in 2 binary. 1kb=1024b;1mb=1024kb; 1024=2^10; 1b=8bit;

Storage type:

The size of the byte data type storage space for various data types

Byte (byte type) 1 2^8

Boolean (Boolean) 2

Integer (integer) 2 2^32

Long (L-integer) 4 2^64

Short () 2 2^16

Double (dual-precision floating-point type) 8

Related units:

b and bit data storage is in bytes (byte), the data transfer is mostly in bits, a bit represents 0 or 1, each 8 bits of a byte (byte, abbreviated B), is the smallest level of information units. 1kb=1024byte; Data type: Byte data type (byte type) is stored in a byte (byte) and can be distinguished by 256 digits, the range 0~255,byte is an unsigned type from 0~255, and cannot represent a negative number. Byte and char byte are byte data types, char is a character data type, and Java uses Char to represent a character. The char type is automatically converted to int when the arithmetic operation is involved, such as the character a will be converted to the corresponding ASCII code 65. Char is used to represent a character, not a word, because a word consumes two bytes. and storing an ANSI character requires only one byte. Note that the emphasis is on ANSI characters, not Unicode characters. Because Unicode takes up to two bytes.

The byte type is the freest one. It takes up a byte, but does not define what this byte does. Char is defined as a unsigned byte type. That is, an unsigned byte. It takes all 8 bits of a byte. The range of data that can be represented is between 0 and 255. If you are sure that the string being processed is a standard ANSI string, it is not necessary to convert it and can be processed directly one byte at a byte. If the string to be processed is variable or a uniform Unicode string is converted, it is processed.

Byte data type-java

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.