1 Byte = 8 bit
1 KB = 1024 Byte = 2^10 Byte
1 MB = 1024 KB = 2^20 Byte
1 GB = 1024 MB = 2^30 Byte
1 TB = 1024 GB = 2^40 Byte
- "A byte is the smallest operable unit"
- Basic data types in C:
- 字符型 char
- 短整型 short
- 整型 int
- 长整型 long
- 单精度浮点型 float
- 双精度浮点型 double
- 无类型 void
- In C, the number of bytes occupied by each data type is fixed. Once the data type is known, the length of the data is known.
- In a 32-bit environment, the lengths of the various data types are generally as follows:
| Description | Character type | Short integer | Integer | Long integer | Single-precision floating-point | Double-precision floating-point |
|---|
| Data type | char | short | int | long | float | double |
| Length | 1 | 2 | 4 | 4 | 4 | 8 |
- Integers are stored in memory in two's-complement form. When read, the two's complement is converted to sign-magnitude form, which is the actual value.
1.原码:即将整数转换为二进制数,转换后的二进制数即为原码。
2.反码:正数的反码和原码相同,负数的反码为最高位作为符号位不变,数值位取反(即0变1,1变0)。
3.补码:正数的补码和原码相同,负数的补码为反码+1。
负数的原码、反码、补码转换方式如下:
原码 -> 反码:最高位符号位不变,数值位取反
反码 -> 原码:最高位符号位不变,数值位取反
反码 -> 补码:反码+1
补码 -> 反码:补码-1
- For integer data types, if the data to be represented is too large, overflow occurs. The overflowing bits are discarded, causing the number actually represented to be incorrect.
Bookmarks:
http://c.biancheng.net/view/vip_1764.html