The study task: Read the second chapter of "in-depth understanding computer system", master integer representation, floating-point number representation and its operation
First, the learning process
- three important digital representations :
- unsigned number : The encoding represents a number greater than or equal to zero, based on the traditional binary notation.
- complement : encoding is the most common method for representing signed integers, which can be positive or negative numbers.
- floating-point Number: encoding is a two-bit base version of the scientific notation for real numbers
overflow : The representation of a computer is to encode a number with a limited number of bits, so that when the result is too large it causes some operations to overflow.
Integers and floating-point numbers have different mathematical properties because different methods are used to handle numbers that are limited.
(整数是编码相对较小的数值范围,但精确度高;
浮点数是编码较大范围的数,但这种表示是近似的)
2.1 Information Storage
A common task for writing machine-level programs is to manually convert between decimal, binary, and hexadecimal bits in the in-place mode.
Boolean algebra: Binary is the core of computer-encoded storage and operation information.
Bit-level operations in C: the C language supports bitwise Boolean operations. With or not, XOR or the same or
A common use is to implement a mask operation.
2.2 Integer Representation
- Integer data type: Depending on the byte allocation, different sizes can represent different ranges of values. Both C and C + + support signed and unsigned numbers by default, and Java supports only signed numbers.
- Unsigned number encoding: B2U4 ([0001]) =0x2^3+0x2^2+0x2^1+1x2^0=1
- Complement code: B2T4 ([1011]) =-1x2^3+0x2^2+1x2^1+1x2^0=-5
(The most significant bit is also called the sign bit, and the weight is -2^w-1.) The sign bit for 1 is negative for 0 is positive. )
- Conversion between signed and unsigned numbers
- Signed and unsigned numbers in C: signed by default, if you want to create an unsigned constant, you must add the suffix u/u.
The principle of C language translation is that the underlying bits remain unchanged. None to have: U2TW. Have to none: T2uw
- Extends the bit representation of a number: converting between integers of different lengths and keeping the values constant.
0扩展:简单的在表示的开头加0。
符号扩展:将补码数字转换成更大类型的数据。规则在表中添加最高有
效位的值的副本。
- Truncate number: Reduces the number of digits that represent a number.
2.3 Integer Arithmetic
Integer arithmetic is actually a kind of modulo operation. A finite word length that represents a number limits the possible range of values, and the result can overflow. The complement provides a flexible way for skills to represent positive numbers and to represent negative numbers, while using the same bit-level implementation as the execution of unsigned arithmetic.
2.4 Floating point
- IEEE floating point representation: Standard v= ( -1) ^sM2^e
which
符号:s 决定这个数是正数还是负数。 尾数:M 二进制小数。 阶码:E 对浮点数加权,权重是2 的E次幂。
Divide the bits of floating-point numbers into three segments and encode them separately:
一个单独的符号位直接编码符号。 K位的阶码字段exp=ek-1……e1e0编码阶段 N位小数字段
- Rounding: A floating-point operation can only approximate the representation of a number operation to find the nearest X value is rounding, the key to the problem is to determine the rounding direction between the two possible values.
向偶数舍入:也叫向最接近的值舍入。是默认方法。将数字向上或向下舍入使的结果的最低有效数字是偶数。其他三种方式产生实际值的确界。
P28 Code and operation
Second, the problems encountered and how to solve
This week's course is mainly the reading and comprehension of textbooks, and the proportion of experiments is small.
With regard to the application of bit patterns, it was doubtful at first that the concept of coercion was not clear. After further understanding, you slowly begin to understand the actual concept of coercion. It is known that coercion type conversions cannot be transferred arbitrarily.
This week, we studied integer representation, floating-point representation and its operation, focusing on homework after class. I have also strengthened the practice of code for the Weak foundation of C language.
20135210 Ellis--Information security system design basics Third Week study summary