**Two’s complement in C**

Assume a word length N, that is, Proposals are available to save a real number relative to a certain base β. One way of arranging such positions is to use the first to indicate the sign, the following N — k — 1 positions for the digits of the integer and the remaining positions for the fractional part. In this way, the sequence of Digits.

The representation of numbers in this form is known as a fixed point representation. The name refers to the fact that when setting Entel number of digits of the fractional part, the point in the base β is fixed to the right of the digit.

Example. Suppose β = 10, N = 11 and k = 6. Then, we have k = 6 digits for the fractional part and N − k − 1 = 4 digits for the whole part.

For a palaban length with fixed digits for the fractional part, the range of values of real numbers that can be represented is within the range [−βN − k, βN − k].

This range is very restrictive: very large numbers and very small fractions cannot be represented (unless a very large word length is used).

For this reason the fixed point representation is not used to implement the representation of real numbers. However, with the convention = 0, the fixed point representation is useful for representing whole numbers.

In the remainder of this section we will discuss how it is implemented in a computer where the base β = 2. Considering the base β = 2, given a word of bits there are 2 different combinations that can be generated. With them we want to represent the positive, negative and zero integers.

There are several ways to proceed, but they all treat the most significant bit (the leftmost) of the word as a bite sign.

If said bit is 0, the integer is positive, and if it is 1, it is negative. Now, the simplest representation that can be considered is the sign-magnitude representation.

In one word, of N bits, while the most significant bit indicates the sign of the integer, the remaining N − 1 bits on the right represent the magnitude of the integer.

This representation, although direct, has several limitations. One of them is that the arithmetic operations of addition and subtraction require separating the bit that represents the sign from the remaining ones to carry out the operation in question. Another limitation is that there are two representations of the number zero 0, namely.

As we indicated, the number of different combinations of a word of N bits is 2N, an even number. Since we have two representations of zero, the same amount of positive integers as negative is represented in the sign-magnitude representation. The range of integers that can be represented then includes the interval [- (2N − 1−1), 2N − 1−1]. Indeed, the largest positive integer has a sign bit 0 and all bits of magnitude are 1, and therefore corresponds to the integer.

The implementation of arithmetic operations of addition and subtraction of integers in a computer is much simpler and more efficient if the sign bit can be treated in the same way as the magnitude bits.

The representation that allows this is the so-called two-complement representation. Since in this representation the implementation of these operations is much simpler, the complement two representation is almost universally used as a representation of the whole numbers in the computer. Like the sign-magnitude representation, the two-complement representation uses the most significant bit as a sign bit (which facilitates checking the sign of an integer), but differs in the way of interpreting the remaining bits. Specifically, for a word length of N bits, a sequence of N binary digits.

Representable integers in complement to two for a word length of N bits. The implementation of arithmetic operations of addition and subtraction of integers in a computer is much simpler and more efficient if the sign bit can be treated in the same way as the magnitude bits.

The representation that allows this is the so-called two-complement representation. Since in this representation the implementation of these operations is much simpler, the complement two representation is almost universally used as a representation of the whole numbers in the computer. Like the sign-magnitude representation, the two-complement representation uses the most significant bit as a sign bit (which facilitates checking the sign of an integer), but differs in the way of interpreting the remaining bits.

Since, as we already indicated, for a word length of N bits there is an even number of different possible combinations, if there is a single representation of 0 then there is an equal number of positive integers as well as of representative integers

This implies, in particular, that there is no two-sided representation