173 / 2 =

86 r 1

43 r 0

21 r 1

10 r 1

5 r 0

2 r 1

1 r 0

0 r 1

Note that an easy way to convert binary to hex (or hex to binary) is break it down into groups of 4 binary digits to 1 hex digit:

Binary: 1010 1101

Hex: A D

Looking at the digits this way also sets us up for a fairly easy conversion to negative values using two’s complement. So to get -173 we can flip all the bits and add one, while taking into consideration the amount of storage used for the number as the leftmost bit will be the sign bit.

Let’s assume an integer of 173 that uses four bytes of storage:

173 Hex: 00 00 00 AD

173 Binary: 0000 0000 0000 0000 0000 0000 1010 1101

Flip bits: 1111 1111 1111 1111 1111 1111 0101 0010

Add 1: 0000 0000 0000 0000 0000 0000 0000 0001

-173 Binary: 1111 1111 1111 1111 1111 1111 0101 0011

-173 Hex: FF FF FF 53