Week Four study report

Source: Internet
Author: User
Tags rounds

representation and processing of informationThe most important figures indicate:No sign(unsigned) encoding is based on the traditional binary notation, which represents a number greater than or equal to zero.complementThe (s-complement) encoding is the most common way of representing signed integers, withA signed integer is a number that can be positive or negative. floating point number(floating-point) coding is a scientific notation for real numbersthe two-base version. Information Store:The machine-level program treats the memory as a very large byte array,called virtual memory . Each byte of the memory is identified by a unique number, called itsAddress(address), a collection of all possible addresses is calledVirtual address space(Virtual address space)Program Object(Program object), which isprogram data, instructions, and control information Pointers also have two aspects: values and types. Its value represents the location of an object, and its type represents the type of object stored in that location (such as integers or floating-point numbers). hexadecimal notation :A byte is made up of 8 bits. In binary notation, its range is 000000002 ~ 111111112; if you use tenA binary integer indicates that its range is 010 ~ 25510. In hexadecimal notation, the value of a byte is 0016 ~ FF16. WordWord size, which indicates the nominal size of integer and pointer data (nominal size) "Char" is named for the fact that it is used to store a single character in a text string, but it can also be used to store integer values. ISO C99 introduces the "long-length" integerThe Number data type allows 64-bit integers. For a 32-bit machine, the compiler must compile the operation of this data type into executionCode for a series of 32-bit operations. (64-bit machine:gcc-m32 Generate 32-bit code)   Addressing and byte orderA rule-the least significant byte in the front-most way, calledSmall End Method(Little endian). This rule is used by most Intel compatible machines. The latter rule-the highest effective byte in the first way, calledBig- Endian method(big endian). Introduction to Boolean algebra:Boolean operations ~ correspond to logical operations not, denoted by symbols in propositional logic. In other words, when P is not true, we say that "p is true and vice versa. Correspondingly, when P equals 0 o'clock, ~p equals 1, and vice versa. Boolean operations & correspond to logical operations and, represented in propositional logic with symbolic ∧. When P and Q are true, we say that P∧q is true. Accordingly, P & Q is equal to 1 only if P = 1 and q = 1 o'clock. Boolean operation | Corresponds to a logical operation or, expressed as a symbolic ∨ in propositional logic. When P or Q is true, we say P∨Q is established. Correspondingly, when P =1 or q = 1 o'clock, p | q is equal to 1. The Boolean operation ^ corresponds to the logical operation XOR, denoted by a symbol in the propositional logic (you know the plus sign inside the circle). logical operations in C languageLogical operators && and | | Bit-level operations that correspond to them & and | The second important difference between the two is that if you evaluate the first parameter to determine the result of the expression, the logical operator does not evaluate the second argument. shift operations in C languageThe C language standard does not explicitly define which kind of right-shift should be used. For unsigned data (that is, integer objects declared with qualifier unsigned), the right shift must be logical x<<k: Move the K-bit left. X>>k: Move Right An integer indicates:notable feature is that the range of values is not symmetric-the range of negative numbers is greater than the range of integersLarge 1 data type long long is introduced in ISO C99 and requires a minimum of 8 bytesrepresentation. (gcc-std=c99)Both *c and C + + support signed (default) and unsigned numbers. Java only supports signed numbers.Binary with unsigned numberIndicates that there is a very important property, that is, each number between 0 ~ 2w-1 has a unique W-bit value encoding. Complement CodeThe most common form of a computer representation of signed numbers is the complement representation. In the definition, the most significant bit of the word is interpreted as a negative right, and the function b2t is the same as an unsigned representation, and each number within the range of values that can be represented has a unique W-bit complement code.  In mathematical terms, B2TW is a double shot-each bit vector with a w is a unique value; in turn, each integer between -2w-1 and 2w-1-1 has a unique binary representation of a bit vector with a length of W. The range of complement is asymmetricalof: | tmin| = | Tmax| + 1, which means that TMin does not have a positive number corresponding to it. 。 This asymmetry occurs because half of the bit patterns (the number of sign bits set to 1) represent negative numbers, and half of the numbers (the sign bit is set to 0) represent non-negative numbers. Because 0 is a non-negative number, it means that a positive number can be expressed less than a negative number. Second, the largest unsigned value is just twice times larger than the maximum of the complement: UMAXW = 2 Tmaxw + 1.   conversion between signed and unsigned numbersMandatory conversions for different numeric types are supported in the C language. The general rule for converting between signed and unsigned numbers with the same word length is that the value may change, but the bit pattern is not changed when a signed number is mapped to its corresponding unsignednumber, negative numbers are converted to large positive numbers, and non-negative numbers remain unchanged. The result of the conversion between unsigned and complement representations. For the value x within the range of 0≤x < 2w-1, we get T2uw (x) = x and U2TW (x) = x. In other words, numbers in this range have the same unsigned and complement representation. For values outside this range, the conversion needs to be added or subtracted by 2w. signed number and unsigned number in C languageAlthough the C languageThe standard does not specify a signed number to be expressed in some way, but almost all machines use a complement. Typically, most numbers areThe tacit view is signed. To create an unsigned constant, you must add the suffix character ' u ' or ' u '. The C language allows conversions between unsigned and signed numbers. The principle of conversion is that the underlying bit representation remains the same. extend the bit display of a numberTo convert an unsigned number to a larger data type, we onlyit is necessary to simply add 0 at the beginning of the representation, which is called a 0 extension (zero extension). Converting a complement number to a larger data type can be performedsymbol Extension(sign extension), the rule is to add a copy of the value of the most significant bit in the representation truncate numbers   Truncating a number may change its value, which is also a form of value overflow.    For an unsigned number that has a value of x, it is truncated to K-bit, and the result is equal to modulo x modulo with a K-th square of 2. For a signed number with a value of x, the conclusion of a class play--the result of modulo operation is also resolved by a signed number integer Arithmetic Overflow: The full integer result cannot be placed into the word length limit of the data type.JudgingIf unsigned operations overflow, such as s=x+y (s, x, y are unsigned), the only reliable criterion is s<x or s<y. Complement non-level representation: The first way to find the level of complement is to complement each bit, and then add 1 to the result. The second way: based on dividing the bit vectors into two parts. Suppose K is the rightmost 1 position, so the bit-level representation of x is like [Xw-1, Xw-2,..., xk+1, 1, 0,..., 0]. (As long as x≠0 will be able to find such a K.) The non-written binary format for this value is [~xw-1, ~xw-2,..., ~xk+1, 1, 0,..., 0]. That is, we reverse all bits on the left side of the position K. The IEEE floating-point standard represents a number in the form of V = ( -1) sxmx2e: • The sign s determines whether the number is negative (S=1) or positive (s=0), while the symbolic bit interpretation for the value 0 is handled as a special case. • Mantissa (Significand) M is a binary decimal that has a range of 1 to 2-ε, or 0 to 1-ε. • The function of the Order code (exponent) E is weighted against the floating-point number, which is 2 of the power of E (possibly negative). Divide the bit representation of a floating-point number into three fields and encode each of these values: • A separate symbol bit s directly encodes the symbol S. K Bit's order field EXP = EK-1...E1E0 encoded Order E.  • N bit decimal segment Frac = FN-1...F1 F0 encoded mantissa m, but the encoded value also depends on whether the value of the Order field equals 0. In the single-precision floating-point format (C languagefloat, the S, exp, and Frac fields are 1 bits, k = 8 bits, and n = 23 bits, respectively, and a 32-bit representation is obtained. In the double-precision floating-point format (the C languageDouble), the S, exp, and Frac fields are 1 bits, k = 11 bits, and n =52 Bits, get a 64-bit representation. Based on the value of exp,the value being encodedCan be divided into three different situations (the last of which there are two variants) Case 1: Normalized values This is the most common case. This is true when the EXP bit mode is neither 0 (value 0) nor all 1 (single-precision value is 255, double-precision is 2047). In this case, the Order field is interpreted as biased(biased) is a signed integer representation of the form. That is, the value of the order is E = E-bias, where e is the unsigned number, and its bitis represented as ek-1...e1e0, while bias is a bias value equal to 2k-1-1 (single precision is 127 and double is 1023). This results in a range of exponential values, 126 to +127 for single precision, and 1022 to +1023 for double precision. Case 2: Non-normalized worth Order field is full 0 o'clock, the number represented is a non-normalized form. In this case, the order value is E = 1-bias, and the value of the mantissa is M = f, which is the value of the small number field, which does not contain the implied beginning of 1. The non-normalized number has two uses: (1) They provide a method that represents a value of 0 (2) that represents a number that is very close to 0.0. They provide a property calledStep- wise Gradual Overflow(gradual underflow), where the possible numerical distribution is evenly close to 0.0. Case 3: The last class of values for the special value is when the point code is all 1. When the decimal field is all 0 o'clock, the resulting value represents infinity, when s = 0 o'clock is +∞, or when s = 1 o'clock is-∞ for floating-point numbers, it is necessary to understand that the number can be expressed is not evenly distributed, the closer the origin of the more dense. RoundingThe IEEE floating-point format defines four different rounding methods. The default partyThe method is to find the closest match, while the other three can be used to calculate upper and lower bounds. (Rounds to (nearest) even, rounds to 0, rounds up, rounds down.) )to even Rounding(Round-to-even), also known as rounding to the nearest value (Round-to-nearest), is the default way to try to find the closest matching valueround to 0 wayRounds the positive number down, rounds the negative numbers up, and gets the value x^, making | x^^ | ≤| x |. The rounding down method rounds both positive and negative numbers down to get the value x, which makes the x-≤x. Rounding up the positive and negative numbers rounded up to get the value x+ to meet the x≤x+. floating point ArithmeticThe IEEE standard specifies a simple rule that is used to determine the results of arithmetic operations such as addition and multiplication. The floating-point values X and Y are considered real, and an operation ⊙ is defined on the real number, and the calculation produces round (x⊙y), which is the result of rounding the exact result of the actual operation. (The advantage is that it can be independent of any specific hardware or softwareimplementation)   floating-point numbers in the C language:When the int, float, and double formats areForcing type conversions, the principle of changing the numeric and bit patterns is as follows (assuming that int is 32-bit):
• Converts from int to float, numbers do not overflow, but may be rounded. • Convert from int or float to double, because double has a larger range (that is, a range that can represent values) and has a higher precision (that is, the number of significant digits), so it retains the exact value. • Convert from double to float because the range is smaller, so the value may overflow into +∞ or-∞. In addition, it may be rounded due to the small accuracy. • Convert from float or double to int, the value will be rounded to 0. For example, 1.999 will be converted to 1, and 1.999 will be converted to-1. Further, the value may overflow. The C language standard does not specify a fixed result for this situation. The Intel-compatible microprocessor refers to the integer indeterminate (integer indefinite) value of the positioning mode [10...00] (tminw with the word length W). A conversion from a floating-point number to an integer that produces a value if a reasonable integer approximation cannot be found for the floating-point number.  Therefore, the expression (int) +1e10 will get-21483648, that is, from a positive value into a negative value.
Floating-point addition is commutative, but not binding. For example, in a single-precision floating-point calculation, the value of an expression ((3.14+1e10) -1e10) is 0.0--because of rounding, the value 3.14 is lost.    On the other hand, the value of an expression (3.14+ (1e10-1e10)) is 3.14.   Floating-point addition does not have a binding, which is the most important group attribute that is missing. Floating-point addition satisfies the monotonicity attribute: If a>=b, then for any x, unless x equals Nan, there is x+a>=x+b.  This attribute is an unsigned or twos complement addition. Computers encode information in bits, usually organized intobytesSequence. When forcing type conversions between unsigned and signed integers of the same length, most C-language implementations follow the principle thatthe underlying bit patternNot change. On the complement machine, for a W-bit value, this behavior is described by the functions T2uw and U2TW. C languageimplicit forced-type conversionsThere will be many results that programmers cannot predict, often resulting in program errors.     Because of the limited length of the encoding, computer operations have completely different properties than traditional integer and real arithmetic. Like most other programming languages, the C language implements a finite integer operation that has some special properties compared to a real integer operation: Because of overflow, the expression x*x can produce negative numbers. However, both the unsigned number and the complement operation satisfymany other properties of integer operations, including binding laws, commutative laws, and distributive laws. This allows the compiler to do a lot of optimizations. We've seen several clever ways to use bit-level arithmetic and arithmetic operations:(1) Using the complement operation,~x+1 is equivalent to-X. (2) Suppose we want a bit pattern like [0,..., 0,1,..., 1], consisting of w-k 0 followed by K 1. These bit patterns are useful for masking operations.    This pattern can be generated by the C expression (1<<k)-1. Take advantage of a property where we want the bit pattern value to be 2k-1. For example, an expression (1<<8)-1 will produce bit pattern 0xFF. Floating-point representations represent real numbers approximately by encoding the numbers into a xx2y form. The most common floating-point representations are defined by IEEE Standard 754. It offers several different precision, the most common beingSingle Precision(32-bit) andDouble Precision(64-bit).     IEEE floats can also represent special values +∞,-∞, and Nan. You must use floating-point arithmetic very carefully, because floating-point arithmetic onlyLimited range and accuracy, and does not follow the general calculationproperties, such as binding . Problems and Summary: Why non-planned values can be uniformly close to 0: Here's an example: if all in decimal, the normalized representation should be 1.23e-2 for a floating-point number similar to 0.0123. However, for some too small numbers, such as 1.23e-130, the number of levels allowed does not meet the need for order size, it is possible to add a leading 0 before the mantissa, as represented by 0.000123e-126. Http://baike.baidu.com/link?url=5mQKSn2yUQDpT3z5qjOJ3VU5vhIScbASXL9Ae0k-Z-mWlBmIVOiBsP6e12WEivrtaw4e9-u-uQpePG  _cl7e52q but non-normalized floating-point numbers are controversial: you can make any floating-point operation work on any floating-point number without generating an overflow exception, but on the other hand it can also cause more occurrences of the divide by 0 errors and Nan. This is a reading summary of the book http://www.ithao123.cn/content-563555.html read, pick and write a little

Week Four study report

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.