1. Twos compliment

Two's complement is the most popular method of signifying negative integers in computer science. It is also an operation of negation (converting positive to negative numbers or vice versa) in computers which represent negative numbers using two's complement. Its use is ubiquitous today because it doesn't require the addition and subtraction circuitry to examine the signs of the operands to determine whether to add or subtract, making it both simpler to implement and capable of easily handling higher precision arithmetic. As well, 0 has only a single representation, obviating the subtleties associated with negative zero.

In the two's complement representation, the most significant bit of a signed binary value indicates the sign. If the sign bit is zero, the value is non-negative binary number. If the most significant (leftmost) bit is 1, the value is negative: the bits contain a two's complement version of the value. To obtain the value of a negative number, all the bits are inverted then 1 is added to the result. If all bits are one the value is negative one; if the sign bit is on but the rest of the bits are off the value is the most-negative number. The most negative number cannot be represented as a positive number with the same number of bits.

A signed 8-bit binary numeral can represent every integer in the range −128 to +127. If the sign bit is 0, then the largest value that can be stored in the remaining seven bits is 27 − 1, or 127.

Using two's complement to represent negative numbers allows only one representation of zero, and to have effective addition and subtraction while still having the most significant bit as the sign bit.

2.Hexadecimal

Hexadecimal numbers are used for the benefit of human programmers, as they are easier to handle than long strings of binary 1s and 0s - with less chance of making an error.  Hexadecimal numbers might be used in printouts of a machine code program which a programmer needs to check or amend.

A common use of hexadecimal numerals is found in HTML and CSS. They use hexadecimal notation (hex triplets) to specify colours on web pages; there is just the # symbol, not a separate symbol for "hexadecimal". Twenty-four-bit color is represented in the format #RRGGBB, where RR specifies the value of the Red component of the color, GG the Green component and BB the Blue component. For example, a shade of red that is 238,9,63 in decimal is coded as #EE093F. This syntax is borrowed from the X Window System.

In URLs, special characters can be coded hexadecimally, with a percent sign used to introduce each byte; e.g., http://en.wikipedia.org/wiki/Main%20Page

The canonical written form of numeric IPv6 addresses represents each group of 16 bits as a separate hexadecimal number, to ease reading and transcription of the 128-bit addresses.

When working with computers we often need to deal with binary data. It is much easier to handle numbers in hexadecimal than in binary (just think of lots of '0's and '1's) and whilst we are more familiar with the base 10 system, it is much easier to map binary to hexadecimal than to decimal since each hexadecimal digit maps to a whole number of bits (410).

Join now!

Consider converting 11112 to base 10. Since each position in a binary (base 2) number can only be either a 1 or 0, its value may be easily determined by its position from the right:

  • 00012 = 110 
  • 00102 = 210 
  • 01002 = 410 
  • 10002 = 810 

Therefore:

This is a very simple example which still requires the addition of 4 numbers; whereas, with some practice, 11112 can be mapped directly to F16 in one step. When the binary number is very much greater, conversion to decimal becomes very much more tedious; however, when mapping to ...

This is a preview of the whole essay