Chapter 1 : Number Base System Flashcards
What is Decimal also called?
- Base 10
- Denary
Binary -> Base 2
Octal -> Base 8
Hexadecimal -> Base 16
1 byte how many bits?
8 bits
How to convert from Decimal to Binary?
- Integer
- Repeat division 2
- No Remainder ( 0 )
- Remainder ( 1 ) , 0.5
- Fraction
- Repeat multiplication 2
- Need to be 0. ( 0.7 )
0.25 x 2 = 0.5 - 0
0.5 x 2 = 1 - 1 ( Top to Bottom )
Ans : 0.01
17
17 / 2 = 8.5 - 1
8 / 2 = 4 - 0
4 / 2 = 2 - 0
2 / 2 = 1 - 0
1 / 2 = 0.5 - 1 ( Bottom to Top )
Ans : 10001
How to convert from Decimal to Octal?
- Integer
- Repeat division 8
- No Remainder ( 0 )
- Remainder ( Remainder )
- Fraction
- Repeat multiplication 8
- Need to be 0. ( 0.7 )
0.25 x 8 = 2 - 2 ( Top to Bottom )
Ans : 0.2
17
17 / 8 = 2.125 - 1
2 - 2 ( Bottom to Top )
Ans : 21
How to convert from Decimal to Hexadecimal?
- Integer
- Repeat division 16
- No Remainder ( 0 )
- Remainder ( Remainder )
- Fraction
- Repeat multiplication 16
- Need to be 0. ( 0.7 )
0.25 x 16 = 4 - 4 ( Top to Bottom )
Ans : 0.4
17
17 / 16 = 1 - 1 ( Bottom to Top )
1 - 1
Ans : 11
What are the rules when converting floating point?
- When there is whole number after multiplying, stop to process and write down answers
How to calculate from binary to decimal?
- Integer
- Repeat multiplication 2
- Fraction
- Repeat division 2
0.101 x 2 = ( 1 x 2^-1 ) + ( 1 x 2^-3 )
= 0.625
Ans : 0.625
1101
1 x 2^3 = 8
1 x 2^2 = 4
1 X 2^0 = 1
Ans : 13
How to calculate from octal to decimal?
- Integer
- Repeat multiplication 8
- Fraction
- Repeat division 8
0.706 x 8 = ( 7 x 8^-1 ) + ( 6 x 8^-3 )
= 0.89
Ans : 0.89
706
7 x 8^2 = 448
0 x 8^1 = 0
6 X 8^0 = 6
Ans : 454
How to calculate from hexadecimal to decimal?
- Integer
- Repeat multiplication 16
- Fraction
- Repeat division 16
0.A1B x 8 = ( 10 x 16^-1 ) + ( 1 x 16^-2) + ( 11 x 16^-3 )
= 0.63
Ans : 0.63
A1B ( 10 - A , 11 - B )
10 x 16^2 = 2560
1 x 16^1 = 16
11 X 16^0 = 11
Ans : 2587
How to convert octal to binary?
- Use 4 2 1
753
4 2 1
1 1 1 = 7
1 0 1 = 5
0 1 1 = 3
Ans: 111101011
0.753
Ans : 0.111101011
How to convert binary to octal?
- Use 4 2 1
10 111 111
010 111 111 ( Add 0 in front when it doesn’t match 4 2 1 )
421
010 = 2
111 = 7
111 = 7
Ans = 277
0.10111111
Ans = 0.277
How to convert hexadecimal to binary?
- Use 8 4 2 1
753
8 4 2 1
0 1 1 1 = 7
0 1 0 1 = 5
0 0 1 1 = 3
Ans: 11101010011
0.753
Ans : 0.11101010011
How to convert from binary to hexadecimal?
- Use 8 4 2 1
1010 1011 1100
8 4 2 1
1 0 1 0 = A ( 10 )
1 0 1 1 = B ( 11 )
1 1 0 0 = C ( 12 )
Ans: ABC
0.101010111100
Ans : 0.ABC
How to convert from Octal to Hexadecimal?
- Use 4 2 1 to convert to binary then use 8 4 2 1 to convert to hexadecimal
1076 ( Octal )
4 2 1
0 0 1 = 1
0 0 0 = 0
1 1 1 = 7
1 1 0 = 6
10 0011 1110
0010 0011 1110
8 4 2 1
0 0 1 0 = 2
0 0 1 1 = 3
1 1 1 0 = E
Ans : 23E
How to convert from Hexadecimal to Octal?
- Use 8 4 2 1 to convert to binary then use 4 2 1 to convert to octal
1F0C ( Hexadecimal )
8 4 2 1
0 0 0 1 = 1
1 1 1 1 = F
0 0 0 0 = 0
1 1 0 0 = C
1111100001100
001 111 100 001 100
4 2 1
0 0 1 = 1
1 1 1 = 7
1 0 0 = 4
0 0 1 = 1
1 0 0 = 4
Ans 17414
How to do binary addition?
Rules
1 + 0 =1
1 + 1 =10
1 + 1 + 1 =11 ( 1 + C , Carry )
Examples
CCC
1011
+ 1111
10010
How to do binary subtraction?
Rule
Borrow 2 from the front
0 1 2 0 1 . 1 2
1 1 0 0 1 0 . 0 0
– 1 0 1 . 1 1
1 0 1 1 0 0 . 0 1
How to do Octal Addition
Rule
** - 8 **and **carry 1 ** to the font when the number is bigger than 7
Example
C
4 4 7
+ 6 2 2
1 2 7 1
9 - 8 =1
10 -8 =2
How to do Octal Subtraction?
- Carry 1 from font numbers when there is not enough number to deduct
Example
4 7 7 12 2 8
5 0 0 4 . 3 0
- 2 6 7 . 1 4
How to do hexadecimal addition?
- If sum exceeds 15 , subtract with 16 and carrying 1 to the next column
Example
1 1
B 8 3
+ A 2 D
1 5 B 0
3 + D = 16 -16 = 0 + Carry
8 + 2 + 1 = 11 ( B )
A + B = 10 + 11 = 21 - 16 = 5 + Carry
How to do hexadecimal subtraction?
- Borrow 16 from the font numbers
Example
9 15 20 22 . 2 16
A 0 4 7 . 3 0
- B 5 8 . 4 1
9 4 F E . E F
List out 3 methods for positive and negative numbers data representation ( 3 )
- Sign and Magnitude
- 1’s Complement
- 2’s Complement
How to view sign and magnitude?
- The 1st bit is sign
- 0 is positive
- 1 is negative
- Remaining bits represent the magnitude
Example
5 = 101
+ 5 = 0101
- 5 = 1101
What are the disadvantages of Sign & Magnitude? ( 2 )
- There are 2 representations (00000000 and 10000000) for the number 0 , which could lead to inefficiency and confusion.
- Positive and negative integers need to be processed separately
What is the difference in 1’s / 2’s Complements Positive values compared with binary?
- Same as binary
5 = 0101
+ 5 = 0101 ( Same as Binary )
- 5 = 1010 ( -ve will use the 1 to 0 , 0 to 1 method )
How to calculate 1’s complement?
- Change 1 to 0 , 0 to 1 when the number is negative
- 5 = 1010 ( -ve will use the 1 to 0 , 0 to 1 method )
What is the disadvantages of 1’s Complement?
- Difficulty in making comparisons and additional complexity involved in
adding numbers.
- Not commonly used
How to convert values to decimal, binary, octal, hex in calculator?
- Mode 2
- Base 3
- Type something in decimal
- Press Shift + HEX / BIN / OCT
How to calculate 2’s Complement?
- Check if it was negative value
- Do 1’s Complement
- Add 1 to the answer of 1’s Complement
Example
-6 in 4 bit using 2’s Complement
6 = 0110
-6 = -0110
= 1001 ( 1’s Complement )
= 1001 + 1
= 1010 ( 2’s Complement )
What are the method introducted for floating point representation?
- IEEE Standard for Floating-Point Arithmetic ( IEEE 754 )
What are the bits range for sign, exponent and mantissa for 8-bit floating point representation ?
- Sign - 1 bit
- Exponent - 3 bit
- Mantissa - 4 bit
What are the bits range for sign, exponent and mantissa for 16-bit floating point representation ?
- Sign - 1 bit
- Exponent - 6 bit
- Mantissa - 9 bit
What are the bits range for sign, exponent and mantissa for 32-bit floating point representation ?
- Sign - 1 bit
- Exponent - 8 bit
- Mantissa - 23 bit
List out ways to convert from decimal to floating point conversion (
- Convert from decimal to binary
- Do normalization
- Let the radix point falls to the right of the leftmost 1 bit
- 111.101 = 1.11101 x 2^2
- 0.0101 = 1.01 x 2^-2 ( Move to right )
- Do sign
- If decimal is positive , it was 0, if it was negative, it was 1
- Do exponent
- Add the exponent with the bias
- 2^1 = 1 + 3 = 4 = 100
- Add 0 to the left
- Do mantissa
- Pick value from 1. { 11101} x 2^2
- 11101
- Add 0 to the right it the bits isn’t enought
- 111010
- Place the answers together with the sequence
- Sign , Exponent , Mantissa
What position to add 0 when the bits isn’t enough?
1. Exponent
2. Mantissa
- Exponent - To the left
- Mantissa - To the right
How to convert from floating point to decimal?
- Formula
( -1 )^s x ( 1 + M ) x 2 ^ E - B
Example
Convert 8 bit floating point 11100111 with 3 bits exponent with 3 bits bias
Sign - 1
Exponent - 110
Mantissa - 0111
M = 2^-2 + 2^-3 + 2^-4
Exponent = 110 = 6
= ( -1 ) ^1 x ( 1 + 2^-2 + 2^-3 + 2^-4 ) x 2^6 - 3
= -1 x 1.4375 x 2^3
= -11.5