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