Data Representation Flashcards
Convert 10101011 from binary to decimal
-Write the column headings over each binary digit, add up the columns with a 1 under them.
(128) (64) (32) (16) (8)(4) (2) (1)
1 0 1 0 1 0 1 1
128+32+8+2+1 = 171
Answer: 10101011 = 171
Convert 5 from decimal to binary
(128) (64) (32) (16) (8)(4) (2) (1)
0 0 0 0 0 1 0 1 (4+1 = 5)
Answer = 00000101
Convert 00110001 from binary to hexadecimal
-split each part into 4 digit chunks
(8) (4) (2) (1) (8) (4) (2) (1)
0 0 1 1 0 0 0 1
2+1 = 3 = 1
-Combine both digits
3 and 1 = 31
Convert 10101110 from binary to hexadecimal
-split each part into 4 digit chunks
(8) (4) (2) (1) (8) (4) (2) (1)
1 0 1 0 1 1 1 0
8+2 = 10 8+4+2 = 14
-In hexadecimal if the number is above 9 it goes into the alphabet
(A) (B) (C) (D) (E) (F)
10 11 12 13 14 15
Therefore 10 = A and 14 = E
-Combine both digits
A and E = AE
how the addition in 8 bit binary of 57+28
57 = 00111001 28 = 00011100
-Use the column method to add them together. If one column’s result is either 2 or 3, then the first bit is carried over to the next column.
Answer: 01010101
What is a bit?
a bit is a binary digit (0 or 1)
What is a byte?
a byte is a collection of 8 bits
it can be used to represent a character (e.g. letter of the alphabet) e.g. the letter “A” is represented by 01000001, “B” is 01000010 (using the ASCII character set)
What is word size?
The word size is the number of bits that the processor can deal with in a single operation. For example a 64 bit PC has a word size of 64 bits (or 8 bytes)
This is why a 64 bit computer is considerably faster than a 32 bit computer.
What is decimal?
Base 10. Decimal uses characters 0 through 9.
What is binary?
Base 2. Binary consists of 2 symbols, 0 and 1. This can be represented electronically as On/Off or Voltage/No voltage
Arithmetic: Binary Addition
Works the same as standard addition.
Each bit is added together and if the result is 2(10 in binary) or 3 (11) then the first bit is carried over to the next column
What is hexadecimal?
Base 16. Hex uses characters 0 through F.
10 - 15 in decimal is A - F in hexadecimal.
Hexadecimal is much easier to read/write than binary. It is used as it keeps numbers much shorter but is also very easy to convert to and from binary.
How do you convert binary to hexadecimal?
- Starting from the right and working left, split the binary number into groups of 4 bits. If the last group has less than 4 bits, simply fill in with 0s from the left.
- Convert these groups into the equivalent hexadecimal digit
What is sign and magnitude?
A method for recording signed integers.
The left-most bit (most significant bit) is used as a sign-bit. If it is zero then the number is positive, if it is a one then the number is negative.
e.g. write -12 as an 8-bit sign and magnitude binary number:
We know that 12 is 00001100
Therefore -12 is 10001100 (the first 1 being the sign bit).
What is the range of numbers that can be stored in 8 bits when using sign and magnitude?
As one bit is being used as a sign bit, the range of numbers that can be stored in 8 bits is -127 to +127.
In unsigned binary the range would have been 0 to +255
What is two’s complement?
is an alternative to sign and magnitude and is more often used in the real world.
The most significant bit is used as a sign bit.
e.g. Write -44 as an 8-bit 2’s complement binary number
We know that 44 is 00101100
To make this negative we “take the 2s complement”. i.e. start at the right hand side of the number, copy each bit up to and including the first 1 and then reverse the rest.
Therefore -44 is 11010100 in 2’s complement.
(the range of numbers that can be held in 8 bits 2’s complement is -128 to +127)
Binary Arithmetic: Subtraction
is an alternative to sign and magnitude and is more often used in the real world.
The most significant bit is used as a sign bit.
e.g. Write -44 as an 8-bit 2’s complement binary number
We know that 44 is 00101100
To make this negative we “take the 2s complement”. i.e. start at the right hand side of the number, copy each bit up to and including the first 1 and then reverse the rest.
Therefore -44 is 11010100 in 2’s complement.
(the range of numbers that can be held in 8 bits 2’s complement is -128 to +127)
What are ranges?
Considering we have 8 bit unsigned binary (i.e. no negatives allowed)
Smallest value: 00000000 (0)
Largest value: 11111111 (255)
Range is 0 to 255 (256 different values)
Considering 8 bit signed 2s Complement binary
Smallest Value: 10000000 (-128)
Largest Value: 01111111 (+127)
Range is -128 to 127 (256 different values). So we can still hold 256 values but we’ve shifted the range down to allow negatives.
Considering 8 bit Sign and Magnitude binary
Smallest value: 11111111 (-127)
Largest value: 01111111 (+127)
Range is -127 to +127 (255 different values). We’ve ‘lost’ a value because there are two ways of storing 0. (-0 and +0)
10000000 = -0
00000000 = +0
What is a logical shift left?
Before: 10011011
All bits move left, bit falls off the end and a 0 appears on the right.
After: 00110110
What is a logical shift right?
Before: 10011011
All bits move right, bit falls off the end and a 0 appears on the left.
After: 01001101
What is an arithmetic shift right?
Before: 10011011
All bits move right, bit falls off the end and a 1 appears in its place to keep same sign bit
After: 11001101
Another example:
Before: 01011011
All bits move right, bit falls off the end and a 0 appears in its place to keep same sign bit.
After: 00101101
What does an arithmetic shift do to decimal numbers?
Before: 00100101 (37 in decimal)
Do an arithmetic shift left
After: 01001010 (74 in decimal)
Therefore Arithmetic Shift Left multiplies a number by 2 (shift twice to multiply by 4, three times for 8 etc.)
Before: 01001100 (76 in decimal)
Do an arithmetic shift right
After: 00100110 (38 in decimal)
Therefore Arithmetic Shift Right divides a number by 2 (shift twice to divide by 4, three times to divide by 8 etc.)
Also works with negative 2’s complement numbers
Before: 11100100 (-28)
Arithmetic shift to right
After: 11110010 (-14)
Binary Arithmetic:Multiplication
6:30 on https://web.microsoftstream.com/video/1bfe4f00-1565-4bff-a067-c4ee633b4d55?channelId=9bcee16e-d1b8-4f3f-8ced-80fb4db4cb9c
How do we convert decimal fraction to binary fraction?
https://web.microsoftstream.com/video/673b6801-0f15-4278-8620-5243327d6827?channelId=9bcee16e-d1b8-4f3f-8ced-80fb4db4cb9c