FOC - A03
Digital Representation
ASCII is a computer language for text that became the standard for transmitting information between computers. Moreover, it translates alphanumeric characters and symbols into computer readable code.
- ASCII is 7-bit characters code consisting value from 0 - 7F16 whereas Unicode consists value from 0 - 10FFFF16
- Sound is captured by microphone and it is converted into a digital signal usually in the form of binary number. Incase of image, it is broken down into individuals pixels.
Number system
- A number can be represent in a computer system by a string of bits (binary number)
- Binary number system (base 2)
- Octal number system (base 8)
- decimal number system (base 10)
- Hexadecimal number system(base 16). it uses 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F.
- N bits in binary number (2^n-1).
- e.g. of 3 bits: 2^3-1 = 8-1 = 7
- In case of hexadecimal number representation, each group of 4 binary bits can be converted into a single digit. If the values is greater then 9, we use A,B,C,D,E,F to represent up to 15.
- eg: converting hexadecimal to binary number:
Signed Number Representation
The leftmost bit is used to indicate the sign:
- 0 for positive
- 1 for negative
Ways to represent signed integers:
- sign and magnitude
- 1's complement
- 2's compliment
Negative numbers have different representations. Such as;
- Sign and magnitude
- 1's complement
- 2's complement
0 + 0 = 0
1 + 0 = 1
1 + 1 = 10 ( binary for 2) 1 + 1 + 1 = 11 (binary for 3)
Eg: 0 0 1 1 +3 0 0 1 0 +2
+ 0 0 1 1 +3 + 0 1 0 0 +4
0 1 1 0 +6 0 1 1 0 +6
Subtraction
Rules and tricks: 0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
0 - 1 = 1 ( borrow 1)
Overflow
Overflow occurs when there are insufficient bits in a binary number representation to the result of arithmetic operation. meaning, when the magnitude of a number exceeds the range allowed by the size of bit.
Overflow in Addition and Subtraction
Overflow indicates that the result was too large
or too small to fit in the original data type. When two signed 2's complement numbers are
added, overflow is detected if: both operands are positive and the result is
negative, or. both operands are negative and the result is positive.
Sign extension
Sign extension of a number is performed by widening the binary number
without changing the sign and value of the number. This process is done by using signed bit
representation, where left most bit represents the sign of the number (0 if
positive and 1 if negative).
For instance: 4 bit number can be written in 8 bit number.
1 1 0 0 = 0 0 0 0 1 1 0 0
Comments
Post a Comment