Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is the difference between bytes and bits in a computer?
What is the difference between bytes and bits in a computer?
I really don't know what you want to ask. Some of your statements are inaccurate and imprecise.

So I have to talk about basic units first.

One bit is a binary bit, for example, 1000 1 1 is 6 bits.

Byte (byte) This is the most basic data type unit in a computer, consisting of 8 bits 1 byte.

Two bytes of a word are called a word, so the word length should be 16 bits * * * two bytes.

Double word (DWORD for short) is just two words, four bytes and 32bit.

In C language, each data type has its storage length. And it is different under a specific platform and a specific compiler.

Because WIN32 platform is widely used, there are many people who use visual studio to do C programs (I learned C language with visual studio 6.0), so I will talk about this situation (in Visual C++ 2005).

Char character type accounts for 1 byte, that is, 8 bits, a data of Char type (for example, a, #,! And so on) with 1 bytes for storage.

Unsigned char unsigned character type accounts for 1 byte, that is, 8 bits. Mainly for compatibility with extended ASCII codes. Because char is represented by 8 bits, the value range is-128-+ 127, and the extended ASCII code cannot be used to represent a total of ***256 characters. Therefore, if the highest sign bit among the 8 bits is also used for counting, 256 characters can be accurately represented, and unsigned characters represent the range of 0-255. The number of exactly 256 can correspond to 256 ASCII characters, including the extended ASCII code.

Chinese characters are stored in computers with built-in codes (a number), but there are only tens of thousands of commonly used Chinese characters, which can be represented by 16 bits (that is, 2 16 equals 65536), so Chinese characters are stored in two bytes. Every two bytes, namely 16bit, correspond to a Chinese character.

Int integer data accounts for 4 bytes or 32 bits, and the length of an int data is stored in 4 bytes.

Short integer Short integer takes up 2 bytes, namely 16 bits, and two bytes.

Long long Integer takes up 4 bytes, which means 32 is 4 bytes.

Float single-precision floating-point type accounts for 4 bytes, that is, 32 bits, and there are 4 bytes left.

Double-precision floating-point type accounts for 8 bytes, that is, 64 bits and 8 bytes.

If you don't use visual studio compiler or programming in win32 environment, the above statement may be incorrect. I suggest you check it out and use int i = sizeof(char) or.

Sizeof(int) looks at the value of i. If i == 4, it means that the current data type accounts for four bytes.