Please enable JavaScript.
Coggle requires JavaScript to display documents.
Data Representation (Binary arithmetic and hexadecimal (Hexadecimal (or…
Data Representation
Binary arithmetic and hexadecimal
Hexadecimal (or hex) is a number system which uses base 16.
As we only have 10 digits, it uses 0-9 and then letters A to F.
Hex to binary
: Divide the denary number by 16 to get the number of 16s (the left-hand hex digit). The remainder gives you the units. Denary 18 becomes: 18 / 16 = 1 r 2 so the hex value for 18 is 12
Binary to hex
: Take a binary word of
8 bits
: 1 1 1 0 0 1 0 1. Divide into two nibbles of 4 bits: 1 1 1 0 0 1 0 1. Convert each nibble into its hex value and rejoin: 1 1 1 0 = 14 = E in Hex + 0 1 0 1 = 5 in Hex. So 1 1 1 0 0 1 0 1 = E5 in Hex.
Benefits of hex
: Much simpler to remember a hex value than a binary value. Quicker to write or type since a hex digit only takes up 1 character, not 4. Less likely to make an error with fewer characters.Easy to convert to and from binary
Computers work with a
fixed number
of bits at a time.
When the result of an addition is too large for the number of bits the computer works with there will be an
overflow error
.
A binary shift left of one bit moves all the bits one place to the left. The vacant bit spaces are filled with zeros. Logical shifts can very quickly multiply or divide a binary number by a factor of two (left shifts multiply and right shifts divide)
Storage units and binary numbers
Computers compromise billions of switches to turn voltage
on and off
.
Power off = 0
Power on= 1
A CPU is made up of
millions of transistors
that can be in one or
two
possible states (on/off) which is why computers use
binary
for machine code.
If you have a number
greater than 255
, it will cause an
overflow error
. The largest number that can be stored is
2^16-1
.
Denary is a base 10 system with 10 digits 0-9.
Binary is a base 2 system with 2 digits 0-1.
Computers used to use 2 bytes to represent an integer. Nowadays, they mostly use 4 bytes.