-
A fixed point number is a representation of a number employed in computers. The decimal point of the number involved in the operation is fixed. Fixed-point numbers are further divided into fixed-point integers and fixed-point decimals.
A fixed-point integer, the decimal point is fixed after the last digit, and is called a fixed-point integer. If the machine word length is n+1 digits, the value is expressed as:
x=x0x1x2...xn, where xi=, 0 i n is (-1) x0
x1*2^(n-1)
x2*2^(n-2)
xn-1*2
xn) value range is.
2^n-1)≤x≤2^n-1
For example, 1111 means -7. A fixed decimal is called a fixed decimal after the decimal point is fixed at the highest place. If the machine word length is n+1 digits, the value is expressed as:
x=, where xi=, 0 i n
Here x0 does not represent a number, only a symbol, if x0=0, it represents x=, and x0=1, it represents. i.e. x= represents a decimal for .
1)^x0x1*2^(-1))
x2*2^(-2)
xn-1*2^(-n+1)
xn*2^(-n))
The numerical range is:
1-2 (-n)) x 1-2 (-n) For example, 1111 represents.
-
A fixed point number is a representation of a number employed in computers. The decimal point of the number involved in the operation is fixed.
Fixed-point numbers are further divided into fixed-point integers and fixed-point decimals.
Fixed-point integer. The decimal point is fixed after the last digit and is called a fixed-point integer. If the machine word length is n+1 digits, the value is expressed as:
x=x0x1x2...xn, where xi=, 0 i n is (-1) x0 * x1*2 (n-1) +x2*2 (n-2) +xn-1*2 + xn).
The range is -(2 n-1) x 2 n-1
For example, 1111 means -7.
Fixed-point decimals. After the decimal point is fixed at the highest place, it is called a fixed decimal. If the machine word length is n+1 digits, the value is expressed as:
x=, where xi=, 0 i n (where x0 does not represent a number, only a symbol, if x0=0, it represents x=, x0=1, then represents.)
That is, the decimal represented by x= is (-1) x0 * x1*2 (-1)) x2*2 (-2) +xn-1*2 (-n+1) +xn*2 (-n))).
The range of values is -(1-2 (-n)) x 1-2 (-n).
For example, 1111 is indicated.
-
The float is stored in 32-bit mode:
1st digit: the sign of the exponent.
The 2nd and 8th digits: the exponential bit, which is represented by 127 surplus yards.
9th digit: mantissa sign bit.
10th 32nd digit: mantissa digits.
See IEEE floating-point notation.
-
Number of fixed points. There are two commonly used expressions of the number of fixed points:
If the decimal place is agreed to be after the lowest digit, the number can only be a fixed-point integer;
If the decimal point position is agreed to precede the highest digit, the number can only be a fixed-point decimal.
If you know the decimal point position convention and the amount of storage space occupied by a fixed number, it is easy to determine the range of its representations.
-
A fixed-point number means that the position of the decimal point in the number is fixed, and there are usually fixed-point integers and fixed-point decimals. In C, it can be considered that integers are fixed-point numbers, and decimal numbers are only float or double types, which are floating-point types, which means that fixed-point numbers in C language are integer types.
-
It can be said that it is a regular number, and there is no need to delve into it.
In addition, there are floating-point numbers, which are more troublesome to figure out.
-
There is no fixed-point decimal (i.e., pure decimal) data type in the C language.
-
int is an integer, that is, only integers can be placed, and there are no decimal points.
float double is a real number, there is a difference between the decimal point and the two, float single precision, double double precision, that is, the size is different, double is large Because the double is large, so int (4 bytes) can not be put into the double, such as 10!
Char is a character type, which only needs one byte and stores ASCII code.
Pointer data, the essence of the C language, is the address of the memory space where a variable is stored.
-
I guess you find a pseudo-**, that is, some functions are used to simply show how this program is implemented, such as the getsign() function, in fact, it tells you to extract positive and negative signs here, you understand this, and the function of this pseudo** function has been achieved. As for what you want to write, you can write a getsign function by yourself, or you can directly replace it with ** with the function of "extracting plus and minus signs".
-
Here's how to convert it:
1. The number is expressed in binary form in the source computer. bai
2. The number of points du is the number of signs and the number of non-symbolic zhi signs, the original code, and the reverse.
Both code and complement are dao is a representation of a signed fixed-point number.
3. The highest digit of a signed fixed-point number is the sign bit, 0 is positive, and 1 is the vice; The original code is the binary form of the number itself.
4. The positive number of [inverse code] and complement code are the same as the original code; The [inverse] of a negative number is the inversion of the unit of the original code except for the sign bit.
1. C language is a general-purpose computer programming language, which is widely used in underlying development. C is designed to provide a programming language that can compile in a simple way, handle low-level memory, generate a small amount of machine code, and run without any runtime support.
2. Although the C language provides many low-level processing functions, it still maintains a good cross-platform characteristic, and the C language program written with a standard specification can be compiled on many computer platforms, and even includes some embedded processors (single-chip microcomputers or MCUs) and supercomputers and other operating platforms.
-
Numbers are represented in binary form in computers.
Numbers are divided into signed and unsigned numbers.
Original, inverse, and complementary are all symbolic fixed-point numbers.
The highest digit of a signed fixed-point number is the sign bit, 0 is positive, and 1 is vice.
The following is an 8-bit integer as an example, and the original code is the binary form of the number itself.
For example 1000001 is -1
0000001 is +1
The inverse and complement of positive numbers are the same as the original code.
The inverse of a negative number is to negate each of its original code except for the sign bit, [-3], inverse=[10000011] inverse=11111100 the complement of a negative number, and then add 1 to the last digit after negating the original code except for the sign bit.
3] complement = [10000011] complement = 11111101 a number and its complement are reversible.
Why do we need to set up a complement?
The first is to enable the computer to perform subtraction:
a-b] complement = a complement + (-b) complement.
The second reason is to unify positive and negative 0s
Positive zero: 000000000
Negative zero: 10000000
Both numbers are actually 0, but their original codes have different representations.
But their complements are the same, they are all 00000000 special attention, if there is a carry after +1, it must be carried all the way forward, including the sign bit! (This is not the same as the reverse code!) )
10000000]
10000000]Anti +1
00000000 (the highest bit overflowed, the sign bit became 0) someone will ask.
Which number of the complement represents 100000000?
Actually, this is a rule, and this number represents -128
So the range that can be represented by the n-bit complement is.
2 (n-1) to 2 (n-1)-1
One more number than the n-bit source code can represent.
-
There is no bai to say that it is in the right place! du
00011000 (COMPLEMENT).
Take a good look at the book, there is a better way to find the complement dao, which is the original (negative).
The return code is from the right direction.
Answer: The first 1 of the left number does not change (the 0 before the first 1 does not change), and the others are negated to the left, wait for the teacher to teach you. It's not easy to understand when you look at the text. Let's see if there is a hint below.
00011000 (COMPLEMENT).
11101000 (original code) If there is a signed bit, the sign bit should not change.
-
The source code can be used.
The meaning of the three sources of come, reverse and complement and the relationship between bai to introduce the conversion relationship between the three and the three: zhi
1. The original code DAO
The original code is the absolute value of the sign bit plus the truth value, that is, the first bit represents the symbol, and the rest of the bits represent the value.
For example, if it is an 8-bit binary:
1] Original = 0000 0001
1] Original = 1000 0001
The first bit is the sign bit.
2. Anti-code. The inverse of a positive number is itself.
The inverse of a negative number is based on its original code, the sign bit remains unchanged, and the rest of the bits are negated.
1] = [00000001] original = [00000001] inverse.
1] = [10000001] original = [11111110] inverse.
The first bit is the sign bit.
3. Complement. The complement of a positive number is itself.
The complement of a negative number is based on its original code, the sign bit remains unchanged, the rest of the digits are negated, and finally +1(i.e. +1 on the basis of the reverse code).
1] = [00000001] original = [00000001] anti = [00000001] complement.
1] = [10000001] original = [11111110] inverse = [11111111] complement.
The first bit is the sign bit.
Note: The complement of the complement is equal to the original code, for example, if the complement of -1 is 11111111, then the inverse code of the 11111111 is 10000000
The complement is 10000001 (the original code of -1).
-
Original code: The highest digit represents the symbol bit. The number of digits remaining. is the binary of the absolute value of this number.
10 of the original code.
8 of the original code. Absolute value: The absolute value of a positive number is itself, and the absolute value of a negative number is minus the negative sign.
2.Reverse code:
The inverse code of a positive number is its original code.
The inverse of a negative number is based on its original code, the sign bit is unchanged, and the other bits are negated.
10 of the anti-code:
10 original code: 00000000 00000000 00000000 00001010
10 of the reverse code: 00000000 00000000 00000000 00001010
8-8 original code: 100000000 00000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
8 inverse code: 11111111 11111111 11111111 11110111
3.Complement:
The complement of a positive number is its original code.
The complement of a negative number is +1 on top of its inverse
Original code: 00000000 00000000 00000000 00001010
10 of the reverse code: 00000000 00000000 00000000 00001010
Complement of 10: 00000000 00000000 00000000 00001010
8-8 original code: 100000000 00000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
8 inverse code: 11111111 11111111 11111111 11110111
Complement of 8: 11111111 11111111 11111111 11111000
-
Shenma is called a fixed number, and I will add or subtract any long decimal number.
Indicates that the remainder of 6 is taken.
In the C language, % stands for remainder (or modulo operation). >>>More
This is an additive function I wrote that can judge overflow: >>>More
Valid variable names for the C language:
First, it can only contain numbers, letters, and underscores. >>>More
The semicolon is the sign of the end of the statement, but the semicolon is not used after the loop, if, and subfunctions such as long long a (int b), and everything else is used, but two semicolons cannot be added, although it will not cause an error, but it may affect the result.
srand(int) is used to set the seed, and then returns a random value each time rand(). >>>More