Information Security system Design Fundamentals third Week study summary

Source: Internet
Author: User
Tags rounds

representation and processing of information The most important figures indicate:unsigned (unsigned) encoding is based on the traditional binary notation, which represents a number greater than or equal to zero. The complement (s-complement) encoding is the most common way to represent signed integers, which are numbers that can be positive or negative. Floating-point number (floating-point) encoding is a two-base version of the scientific notation for real numbers. Information Store:Machine-level programs treat memory as a very large array of bytes, called virtual memory. Each byte of the memory is identified by a unique number, called its address, and the collection of all possible addresses is called the virtual address space program object, which is program 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 consists of 8 bits. In binary notation, its range is 000000002 to 111111112, and if it is represented by a decimal integer, 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. The "Long" integer data type introduced by ISO C99 allows 64-bit integers. For a 32-bit machine, the compiler must compile the operation of this data type into code that performs a series of 32-bit operations. (64-bit machine: Gcc-m32 generates 32-bit code)   Addressing and byte orderA rule-the least significant byte in the front-most way, called the small-end method (little endian). This rule is used by most Intel compatible machines. The latter rule-the most significant byte in the front way, called the 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:The notable feature is that the range of values is not symmetrical-the range of negative numbers is larger than the range of integers 1 data type long long is introduced in ISO C99, it requires at least 8 bytes of representation. (GCC-STD=C99) both *c and C + + support signed (default) and unsigned numbers.  Java only supports signed numbers. The binary representation of unsigned numbers has an important attribute, which is that each number between 0 and 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 the complement is asymmetrical: | tmin| = | Tmax| + 1, that is, 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 unsigned number, 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 language standard does not specify a symbolic number to take some representation, almost all machines use a complement. Usually, most numbers are assumed to be 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 simply add 0 to the beginning of the representation, which is called the 0 extension (zero extension). Convert a complement number to a larger data type you can perform a symbol extension (sign extension), where 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: Full integer results cannot be placed into the word length limit of the data type.    to determine whether 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 complement of a bit 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 &NBSP;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 single-precision floating-point format (float in C), the S, exp, and Frac fields are 1 bits, k = 8 bits, and n = 23 bits, respectively, to get a 32-bit representation.   in double-precision floating-point format (double in C), the S, exp, and Frac fields are 1-bit, k = 11-bit, and N-= 52 bits, respectively, resulting in a 64-bit representation.    according to exp value, the encoded value can be divided into three different cases (the last case has two variants)   Case 1: Normalized value 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 a signed integer in the form of bias   (biased)Number. That is, the value of the order is E = E-bias, where e is an unsigned number, its bit   is represented as EK-1...E1E0, and Bias is a bias value equal to 2k-1-1 (single precision is 127, double precision is 1023). This results in a range of exponential values, 126 to +127 for single precision, and 1022 to +1023 for double precision.   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 called progressive overflow (gradual underflow), where the possible numerical distributions are uniformly close to 0.0.   3: Special value The last class of values 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 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.) Rounding to even numbers (Round-to-even), also known as rounding to the nearest value (Round-to-nearest), is the default way to try to find a closest match value to 0 rounding, rounding the positive number down, rounding the negative up, getting 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 implemented independently of any specific hardware or software)   floating-point numbers in the C language:    When casting between int, float, and double formats, the principle of changing numeric and bit patterns is as follows (assuming that int is 32-bit):    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 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 into byte sequences. When forcing type conversions between unsigned and signed integers of the same length, most C language implementations follow the principle that the underlying bit patterns are unchanged. On the complement machine, for a W-bit value, this behavior is described by the functions T2uw and U2TW. The implicit coercion type conversion of C language can result in many programmers ' unpredictable results, 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 compared to a real integer operation, with some special properties:    because of overflow, the expression x*x can produce negative numbers. However, both unsigned and complement operations satisfy many of the 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 that is like [0,..., 0,1,..., 1], consisting of a w-k  0 followed by a K 1. These bit patterns are useful for masking operations. This pattern can be generated through the C expression (1<<k) -1  .    is using a property that we want the bit pattern to be the value of 2k-1. For example, an expression (1<<8) -1  will produce a bit pattern of 0xFF. Floating-point representations represent real numbers approximately by encoding the numbers into a xx2y form. The most common floating-point representation is defined by IEEE Standard 754Of It offers several different accuracies, the most common being single-precision (32-bit) and double-precision (64-bit). IEEE floats can also represent special values +∞,-∞, and Nan.      must use floating-point operations very carefully, because floating-point operations have limited range and precision, and do not adhere to the general calculation   properties, such as binding.     problems and Summary:  1. Not very understanding of the reverse angle. 2. Complement code, signed number and unsigned number conversion between, this part, did not understand, feel a bit messy, exercise 2.19 will not 3. Note operators that differentiate between Boolean and logical operations , as well as the special meaning of the logical operation (the non-0 parameter is expressed as true, that is 1, the 0 parameter is false, the return value is only 0 or 1, can be understood as the result of the proposition is only true two possible), do not confuse. (Exercise 2.14) 4. Exercises not understood 2.33, 2.39; Knowledge points: IEEE floating point represents three different cases of encoded values, corresponding to exercise: 2.47, 2.52.

Information Security System design basics Third week study summary

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.