Decimal point original code inverse code complement example questions and answers

Primary, inverse, and complement of decimals

Converted to binary is the integer part divided by two to make 1

Decimal part multiplied by two until it becomes 1

Significant bit 0 means positive and 1 negative

Positive: primary = complement

Negative:

Primary

=

Positive part (with negative sign removed) of binary value and sign bit (leftmost bit) is 1

Inverse

=

Positive part ( minus sign removed) and the sign bit (leftmost bit) is 1

Inverse code

=

Binary value of the positive part (minus sign removed), inverted by bit

Complement code

=

Inverse code

+

1

Decimal point is still in point

Fixed-point numbers

The so-called fixed-point numbers are numbers in which the position of the decimal point is fixed. In computers, fixed-point numbers are often used to represent integers and pure decimals, called fixed-point integers and fixed-point decimals, respectively.

Fixed-point integer: The highest binary digit of a number is the number sign bit, which is used to represent the sign of the number; while the decimal point’s position is defaulted to be after the lowest (i.e., right-most) binary digit, but the decimal point does not take up a separate binary digit, as follows:

0

1001010010001010001

Number sign bit

Numerical bit

Numerical bit

Numerical bit

Numerical bit

Numerical bit

Number sign bit

Numeric bits

Decimal bits

So, in a fixed-point integer, all the binary bits to the right of the number sign bit represent an integer value.

Fixed-point decimals: The highest binary digit of a number is the number sign bit, which is used to represent the sign of the number; the decimal point is positioned after the number sign bit by default, and does not take up a separate binary digit, as shown here:

0

1001010010001010001

Number Sign Bit|Decimal Bit

Value Bit

Thus, in a fixed-point decimal, all the binary digits to the right of the number sign bit represent a pure decimal.

2. Floating-point numbers

In computers, fixed-point numbers are usually used to represent only integers or pure decimals. Numbers that have both an integer and a decimal part are usually represented as floating point numbers because the decimal point is not in a fixed position.

Floating-point numbers, as they are called in computers, are numbers in which the position of the decimal point is not fixed. Generally, a decimal number D with both integer and decimal parts can be expressed in the following form:

D=R*10N

Where R is a pure decimal number and N is an integer.

Such as a decimal number 123.456 can be expressed as: 0.123456 * 103, decimal decimal decimal 0.00123456 can be expressed as 0.123456 * 10-2. pure decimal R, the first digit after the decimal point is generally non-zero numbers.

Similarly, for binary numbers that have both integer and decimal parts, the mouth can also be expressed in the following form:

D = R*2N

Where R is a binary fixed-point decimal, known as the trailing digit of D; N is a binary fixed-point integer, known as the ordinal code of D, which reflects the actual position of the decimal point of the binary number D. In order to represent the maximum number of digits in a finite number of binary digits, the first digit after the decimal point (i.e., one bit after the sign bit) of a fixed-point decimal R is generally a non-zero digit (i.e., a “1”).

In computers, a string of consecutive binary bits is usually used to store a binary floating-point number, whose general structure is shown in the following diagram:

Ordinal symbol

N

Numeric symbol

R

|

Ordinal code section

|

Decimal bits

Trailing number section

how to calculate the negative decimal original code, complement, inverse code and shift code, such as (-0.3125) decimal

The first decimal point indicates positive or negative, negative 1, first regardless of positive or negative, the integer part is 0 do not have to seek, the decimal part of the 0.3125 * 2 = 0.625, the integer part of the 0, the second decimal point is 0, and then calculate the 0.625 * 2 = 1.1.25, the integer part is 1, the second digit after the decimal point is 1, remove the integer 1,0.25*2=0.5, the integer part is 0, the third digit is 0,0.5.*2=1, the last digit is 1, the original code (1.0101). (Check that 2^-2+2^-4=0.25+0.0625=0.3125). For negative numbers, the inverse code is the original code inverted (1.1010), and for negative numbers, the complement is the original code inverted + 1 (1.1011), and there is no shift code for decimals.