"Csapp" second, the expression and processing of information

Source: Internet
Author: User

Three important numbers: unsigned, complement, floating point.

"One" Information store

The smallest unit is bytes, at the operating system level, you only need to focus on addresses. The system divides the memory space into more manageable units and holds different program objects (program data, instructions, control information)

1, 16 binary notation: a byte is represented by two 16 characters, 00-ff. Exercise : 16 binary, 10 binary, 2 binary conversion.

2, Word: Length determines the maximum size of the virtual address space. 32-bit computer virtual address space is 2^32, which is 4GB

3, Data size: integer short2/int4/long word/longlong8, floating-point float4/double8, Char1, char *

4. Addressing and byte order: rules for Multi-byte objects: Address + how to arrange.

Small End method: The front address holds the small bit, the back address holds the large bit, the big-endian opposite

Possible scenarios: 1, the network transmits binary data. 2, Disassembly: From instruction byte-level representation to assembler 3, coercion type conversion

5. String: The end is 0x00 (NULL, ASCII code is 0), text data is better than binary data platform independence

6, the Code: binary encoding is not compatible.

7, c median operation: ~ | & ^, common usage: oneself and oneself do different or, get is oneself. The mask operation.

8, C in the logical Operation:&& | | !,

9, C shift operation: Shift left << right Shift:

Logical right Shift: Left 0

Arithmetic right shift: left side to fill the highest bit,

Unsigned data is the logical right SHIFT, signed data, arithmetic right shift.

"Integer Representation"

The first digit of the signed number is the negative 2^ (n-1),

Signed and unsigned switching:

Signed number and unsigned number operation in C, signed number automatically converted to unsigned number!

This is a pit, and the best solution is to never use unsigned numbers.

Bit representation of extended numbers: unsigned 0 extension, signed symbol extension (similar to logical right shift)

"Integer Operation"

1. Unsigned addition:

2. Signed addition:

3, the complement of non-

4. Non-symbolic multiplication

5. Complement multiplication

High-level inconsistency, low-level is the same way of processing.

6, multiplied by constants: multiplication usually requires more than 10 clock cycles, but multiplying constants can be replaced by shift and addition operations.

For example: 14 = 2 + 2^2 + 2^3, then x*14 = (x << 3) + (x << 2) + (x<<1)

7, divided by the power of 2: Logical right SHIFT, arithmetic right SHIFT + offset (see later)

"Floating point"

IEEE Standards

1. Binary decimals: Similar to decimal decimal mechanism

2. IEEE floating point representation: Sign + exp + frac:

Exp: Unsigned number-offset (offset of 2^ (k-1)-1)

Float:1 + 8 + 23

Double:1 + 11 + 52

3. Rounding and floating point arithmetic (pending pits)

"Csapp" second, the expression and processing of information

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.