-
This is not 100, but a binary 4 because the decimal point is shifted 4 digits to the left.
-
IEEE 754 specifies the way to represent floating-point values: single-precision (32-bit), double-precision (64-bit), single-precision binary decimal places, and uses a slow balance 32-bit store, which is divided into sign bits (S), exponential bits (exp), and significant digits (fraction).
From left to right, they are 1 digit, 8 digits, and 23 bits
The exponential part is expressed in the form of a so-called partial positive value, and the actual value is the sum of the expressed value and a fixed value (127 in the case of 32 bits).
For example, if there is a float to make a point, how do you convert it to hexadecimal?
First it will be converted to binary form:
Normalize it: Adjust it so that the first digit of Luwu's actual number is greater than 1 and less than 2
The basic prototype came out.
s:0exp : 2+127 (decimal) =129 (decimal) = 10000001 (decimal).
fraction : 10111010001111010111000 (Note: 1 before the decimal point is not required).
Combine it: 0 10000001 10111010001111010111000
4 0 d d 1 e b 8 original.
-
In the binary of floating-point numbers, the integer and decimal parts of the floating-point numbers are converted separately and then merged because of the different conversion methods for integers and decimals.
1. Floating-point integers are converted to binary integers"Divide by 2 and take the remainder and arrange them in reverse order"Law. Removing the floating-point integer with 2 gives you a quotient and remainder; This is done until the quotient is zero, and then the remainder obtained first is used as the lower significant digit of the binary number, and the remainder obtained later is used as the high significant digit of the binary number, and then arranged in order.
2. Floating-point decimal is converted to binary decimal number"Multiply by 2 and round up, in order"Law. Multiply the floating-point decimal by 2 to get the product, and take out the integer part of the product until the decimal part of the product is zero, or the required accuracy is reached. Then arrange the integer parts in order, the integer taken first is used as the high significant digit of the binary decimal place, and the integer taken later is taken as the low significant digit. Dust lead.
-
For example: Convert to a single-precision binary representation.
The integer part is 12, and the binary is 1100; The decimal part, binary is. 1, connect them first, and take 24 digits from the first 1 count (0 is added later):
This part is the significant number. (Connect the two parts before and after the decimal point and then take out the 1 before the head, which is the mantissa number).
To move the decimal point to the end of the first 1, you need to move 3 digits to the left (000 00000000 0000 0000 *2 3), plus the offset 127:127+3=130, the binary is 10000010, which is the order code.
is a negative number, so the sign bit is 1. Connect the symbol bits, the order and the mantissa together. Note that the first digit of the mantissa is always 1, so it is stipulated that the 1 of this digit is not saved, and only the last 23 digits are taken:
Binary is a system of numbers that is widely used in computing technology. Binary data is a number represented by two numbers, 0 and 1. Its base is 2, the carry rule is "every two into one", and the borrowing rule is "borrow one as two".
Binaries are the base operators of the binary system, which is the base value; The basis of computer computing is binary. The base of a computer is binary. After the advent of electronic computers, it was too complicated to use electron tubes to represent the ten states, so there were only two basic states in all electronic computers, on and off.
In other words, the two states of the base of the tube determine that the tube-based electronic computer adopts binary to represent numbers and data.
A floating-point number is a numerical representation of a number that belongs to a specific subset of rational numbers, and is used in computers to approximate any real number. Specifically, this real number is obtained by multiplying an integer or fixed-point number (i.e., mantissa number) by the integer power of a certain base (usually 2 in a computer), similar to the scientific notation of the base 10.
-
Various integer types are sufficient for most software development projects. However, programs oriented towards finance and mathematics are often usedFloating-point numbers。Floating-point numbers in C are of type float, double, and long double.
First, let's understand floating-point numbers in terms of scientific notation.
Let's put scientific notation in another way:
There are four parts in the above equation:
The numerical part of the order and the order code is collectively referred to as the order code, and the numerical part of the number symbol and the mantissa is collectively referred to as the mantissa number.
In the formula, r is the bottom of the floating-point order, that is, 10 in the Kechang noodle notation, but in fact, this bottom does not necessarily have to be 10, it can be 4 and 8, if the floating-point number is binary, then r= is the order code, m is the mantissa number. So in a computer, by setting r to 2 by default, and then storing the binary of e and m, you can represent a floating-point number.
Here, in contrast to , in scientific notation, some mantissa numbers are omitted, which corresponds to the rounding error of floating-point numbers that can occur in C. Because the number of bits n of the mantissa number reflects the precision of the floating-point number. Usually floats occupy 32 bits (i.e. 4 bytes), of which 8 bits are used to represent the order code and the remaining 24 bits are used to represent the mantissa number.
A limited number of 24 digits can only represent a limited number of ante-resistant numbers. =16777216, there are 8 decimal digits, so the number of significant digits that can be represented by the foalt type is usually 7 or 8 digits.
How does the computer use binary to organize and store the above-mentioned order codes and mantissa numbers? There is an IEEE 754 standard, and the C language uses the IEEE 754 standard to represent floating-point numbers.
In the case of decimal numbers, if you convert to float, the standard specifies the following format:
The IEEE 754 standard specifies that the commonly used floating-point number formats are short floating-point numbers (single-precision, float), long floating-point numbers (double, double), and temporary floating-point numbers (long double), as shown in the following table.
-
Decimal number -27 128 is a floating-point representation.
Hello, happy to answer your <>
Floating-point representation of decimal number -27 128: Floating-point representation of decimal number -27 128, first of all, the sign bit is 1 because it is a negative number. Second, it will be converted to a binary number.
The binary representation of the integer part is: 0. The binary representation of the decimal part can be obtained by multiplying by 2 rounding:
Therefore, the binary representation is: two).
Insight and then, find the index level. Since this is a normalized floating-point number, the decimal point is moved to the left until the first digit is 1, and it is moved by 4 digits, so the exponential digit is 4+127=131. Denote the base of 131 as 10000011 (two) and add a 0 in front of it to get the 8-bit exponent bit.
-
A decimal number can be written as a pure decimal multiplied by 10 to the power of a decimal number, and similarly, a binary number can be written as a pure decimal multiplied by 2 to the power of 2. Volpai for example,; In general, any binary n can be expressed as n=2j s;
where j is a binary number, called a step code; If there are positive and negative signs, the positive and negative signs are called order symbols; s is a pure decimal, which is called a mantissa number; A number symbol, which refers to the symbol of the entire number of n.
The range that floating-point numbers can represent is determined by the number of digits of the order code, and the accuracy is determined by the number of digits of the mantissa number.
-
At present, all data in computers is represented in binary, and the internal representation of floating-point numbers is also binary.
-
Floating-point numbers are the type of data used in computers to represent real numbers. In computers, floating-point numbers are usually composed of three parts: numbers, orders, and mantissas. Among them, the number character represents the positive and negative of the floating-point number, the order code indicates the size of the floating-point number, and the mantissa table key indicates the accuracy of the floating-point number.
Some parameters for floating-point numbers are given in the question, including: 4 digits for mantissa numbers, 2 digits for order codes, 1 digit for order symbols, and 1 digit for number symbols. Based on these parameters, we can get a floating-point representation of a negative number.
First, a negative number has a symbol of 1, which means that it is a negative number.
Secondly, the order code of the negative number is 2, and we can express it in binary form, that is, the manuscript is called 10, and then add 0 to the left of it, so that its number of digits is the number of order digits given in the question, that is, 2, to get 0010.
Next, the mantissa of a negative number is , and we can express it in binary form, i.e., , and then add 0 to the right of it, so that its number of digits is the mantissa number given in the subject carry, i.e., 4, to get 0100.
Binary is a system of numbers that is widely used in computing technology. Binary numbers are numbers represented by two numbers, 0 and 1. Its base is 2, the carry rule is "every two into one", and the borrowing rule is "borrow one as two". >>>More
It can be like this: for example, multiply it by the binary number of the base. >>>More
If it's a method, I can give you a natural language description of how the decimal integer part n can be converted to binary as follows: >>>More
1.Binary 1000 is replaced by 16.
With the 8421 conversion method, that is, from left to right, 8*1+4*0+2*0+1*0=0x8, this is the universal conversion method for all hexadecimal to binary, bit-to-bit alignment conversion, multiply by 8421 respectively, and then add up. If the binary number. >>>More
What is the base system?
If it's not a decimal one: >>>More