1.1.1 Units of Data and Representing Numbers
Aims
Understand the different units of data and convert between them
Understand the need for different numbering systems in Computer Science
Convert between denary numbers, binary numbers, hexadecimal values and binary coded decimal values
Data in computer systems is stored in binary form 1’s and 0’s
“Bit” (Binary Digit) is the smallest unit of data and is either a 1 or 0 (true or false respectively)
“Nibble” is half a byte and therefore 4 bits - remember 2 nibbles make a byte!
“Byte” contains 8 bits
There are two types of prefixes to be used when calculating size of data: Binary (Base-2) and Decimal (Base-10)
SI (Systems International) units - easier for non experts to remember
2005 IEEE (Institute of electrical and electronic engineers) binary prefix became standard for accurate storage size
Binary Prefix (Base-2): each level is based on powers of 2
Unit | Power | Value |
Kibibyte (Kibi - Kilobinary) | 210 | 1,024 |
Mebibyte (Mebi - Megabinary) | 220 | 1,048,576 |
Gibibyte (Gibi - Gigabinary) | 230 | 1,073,741,824 |
Tebibyte (Tebi - Terabinary) | 240 | 1,099,511,627,776 |
Decimal Prefix (Base-10): each level is based on powers of 10
Unit | Power | Value |
Kilo (K) Kilobyte | 103 | 1,000 |
Mega (M) Megabyte | 106 | 1,000,000 |
Giga (G) Gigabyte | 109 | 1,000,000,000 |
Tera (T) Terabyte | 1012 | 1,000,000,000,000 |
E.g. Bits to Gigabytes X/8=Bits to Bytes=/1000=XKilobytes/1000=XMegabytes/1000=Gigabytes
E.g. Gibibytes to bits X*1024=XMebibytes*1024=XKibibytes*1024=XBytes*8=Bits
When converting be careful of Prefixes!
Denary - Base 10- Numbers 0-9 - works from right to left moving up in units of 10
Binary - Base 2 (Geometric sequencing) - Used in computers as they’re made up of circuits and switches (electricity) that are either 1 (on) or 0 (off) - works right to left doubling in value 128/64/32/16/8/4/2/1
No way to know for certain what a particular pattern of bits represents until you interpret the data, same binary code could be interpreted as ASCII/pixel amount/wavelength etc.
Binary to Denary - 173
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
128 | 0 | 32 | 0 | 8 | 4 | 0 | 1 |
Denary to Binary - 98
Start from biggest number equal to or lower than Denary and enter 1, if higher enter 0, check by adding up numbers at the end
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 |
0 | 64 | 32 | 0 | 0 | 0 | 2 | 0 |
Base 16Numbers 0-9 Letters A-F
Shorthand for binary therefore faster and easier to convert to/from
fewer mistakes as its 2 digits - each digit is 4 bits
commonly used in colour codes RGB, assembly line programs, error codes and memory dumps
Binary to Hexadecimal
Split binary into groups of 4 bits, convert into denary and convert to Hex using table
e.g 10011111 is 9F in hexadecimal
8 | 4 | 2 | 1 | 8 | 4 | 2 | 1 | |
1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | |
8 | 1=9 | 8 | 4 | 2 | 1=15 |
Denary | Binary | Hex |
0 | 0000 | 0 |
1 | 0001 | 1 |
2 | 0010 | 2 |
3 | 0011 | 3 |
4 | 0100 | 4 |
5 | 0101 | 5 |
6 | 0110 | 6 |
7 | 0111 | 7 |
8 | 1000 | 8 |
9 | 1001 | 9 |
10 | 1010 | A |
11 | 1011 | B |
12 | 1100 | C |
13 | 1101 | D |
14 | 1110 | E |
15 | 1111 | F |
Binary Coded Decimal
BCD form of binary system that uses 4 bits to represent a denary digit
denary converted individually into binary
Four bits used to represent 0-9 (easier to read)
Compared to binary - less efficient use of memory as 4 bits used to store each denary value
But useful when precision is crucial & easier to convert to Denary making it easier for display devices i.e clocks and calculators (as they don’t code well using binary numbers)
Converting Denary/Binary/Hexadecimal
Tip - easier to convert denary to binary then hexadecimal
Denary | 12 | |||||||
Binary | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | |
Nibble | 8 | 4 | 2 | 1 | 8 | 4 | 2 | 1 |
Hexadecimal | 0 | C |
Convert each Nibble into Hexidecimal - remember the Hexadecimal digits are separate e.g 6 and 4 not sixty four
To reverse Hexadecimal into Denary flip the table - A=10, sort it into Binary using Nibble then add all the binary up to make Denary
Aims
Understand the different units of data and convert between them
Understand the need for different numbering systems in Computer Science
Convert between denary numbers, binary numbers, hexadecimal values and binary coded decimal values
Data in computer systems is stored in binary form 1’s and 0’s
“Bit” (Binary Digit) is the smallest unit of data and is either a 1 or 0 (true or false respectively)
“Nibble” is half a byte and therefore 4 bits - remember 2 nibbles make a byte!
“Byte” contains 8 bits
There are two types of prefixes to be used when calculating size of data: Binary (Base-2) and Decimal (Base-10)
SI (Systems International) units - easier for non experts to remember
2005 IEEE (Institute of electrical and electronic engineers) binary prefix became standard for accurate storage size
Binary Prefix (Base-2): each level is based on powers of 2
Unit | Power | Value |
Kibibyte (Kibi - Kilobinary) | 210 | 1,024 |
Mebibyte (Mebi - Megabinary) | 220 | 1,048,576 |
Gibibyte (Gibi - Gigabinary) | 230 | 1,073,741,824 |
Tebibyte (Tebi - Terabinary) | 240 | 1,099,511,627,776 |
Decimal Prefix (Base-10): each level is based on powers of 10
Unit | Power | Value |
Kilo (K) Kilobyte | 103 | 1,000 |
Mega (M) Megabyte | 106 | 1,000,000 |
Giga (G) Gigabyte | 109 | 1,000,000,000 |
Tera (T) Terabyte | 1012 | 1,000,000,000,000 |
E.g. Bits to Gigabytes X/8=Bits to Bytes=/1000=XKilobytes/1000=XMegabytes/1000=Gigabytes
E.g. Gibibytes to bits X*1024=XMebibytes*1024=XKibibytes*1024=XBytes*8=Bits
When converting be careful of Prefixes!
Denary - Base 10- Numbers 0-9 - works from right to left moving up in units of 10
Binary - Base 2 (Geometric sequencing) - Used in computers as they’re made up of circuits and switches (electricity) that are either 1 (on) or 0 (off) - works right to left doubling in value 128/64/32/16/8/4/2/1
No way to know for certain what a particular pattern of bits represents until you interpret the data, same binary code could be interpreted as ASCII/pixel amount/wavelength etc.
Binary to Denary - 173
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
128 | 0 | 32 | 0 | 8 | 4 | 0 | 1 |
Denary to Binary - 98
Start from biggest number equal to or lower than Denary and enter 1, if higher enter 0, check by adding up numbers at the end
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 1 | 1 | 0 | 0 | 0 | 1 | 0 |
0 | 64 | 32 | 0 | 0 | 0 | 2 | 0 |
Base 16Numbers 0-9 Letters A-F
Shorthand for binary therefore faster and easier to convert to/from
fewer mistakes as its 2 digits - each digit is 4 bits
commonly used in colour codes RGB, assembly line programs, error codes and memory dumps
Binary to Hexadecimal
Split binary into groups of 4 bits, convert into denary and convert to Hex using table
e.g 10011111 is 9F in hexadecimal
8 | 4 | 2 | 1 | 8 | 4 | 2 | 1 | |
1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | |
8 | 1=9 | 8 | 4 | 2 | 1=15 |
Denary | Binary | Hex |
0 | 0000 | 0 |
1 | 0001 | 1 |
2 | 0010 | 2 |
3 | 0011 | 3 |
4 | 0100 | 4 |
5 | 0101 | 5 |
6 | 0110 | 6 |
7 | 0111 | 7 |
8 | 1000 | 8 |
9 | 1001 | 9 |
10 | 1010 | A |
11 | 1011 | B |
12 | 1100 | C |
13 | 1101 | D |
14 | 1110 | E |
15 | 1111 | F |
Binary Coded Decimal
BCD form of binary system that uses 4 bits to represent a denary digit
denary converted individually into binary
Four bits used to represent 0-9 (easier to read)
Compared to binary - less efficient use of memory as 4 bits used to store each denary value
But useful when precision is crucial & easier to convert to Denary making it easier for display devices i.e clocks and calculators (as they don’t code well using binary numbers)
Converting Denary/Binary/Hexadecimal
Tip - easier to convert denary to binary then hexadecimal
Denary | 12 | |||||||
Binary | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | |
Nibble | 8 | 4 | 2 | 1 | 8 | 4 | 2 | 1 |
Hexadecimal | 0 | C |
Convert each Nibble into Hexidecimal - remember the Hexadecimal digits are separate e.g 6 and 4 not sixty four
To reverse Hexadecimal into Denary flip the table - A=10, sort it into Binary using Nibble then add all the binary up to make Denary