Numbering Systems Notes
Converting Fractions
To convert a fractional decimal value to binary, repeatedly multiply the decimal fraction by 2.
- Example: Convert 11.375 to binary.
- First, convert 11 to binary:
- Then, convert 0.375 to binary:
- 0.375 * 2 = 0.750 --> 0
- 0.750 * 2 = 1.500 --> 1
- 0.500 * 2 = 1.000 --> 1
- Therefore,
- Finally,
- Example: Convert 11.375 to binary.
Exercise:
- Convert the following numbers to their binary equivalents.
- Convert the following numbers to their binary equivalents.
Exercise:
- Convert the following decimal number to binary?
Adding Binary Fractions
To add binary fractions, align the decimal points and add as usual.
- Example:
```
1011.00.011
1011.011
```Example:
```
1
110.011.011
--------
111.101
```
Binary Subtraction
- Use 2's complement representation for subtraction.
- Rewrite as
- Example: Solve
- Rewrite as
- Convert 76 to binary:
- Find the 1's complement:
- Find the 2's complement by adding 1:
- Add the numbers:
1 1
01111111
+ 10110100
---------
1 00110011
```
*
* 127 - 76 = 51
* When computing, if the carry bit exists this represents overflow.
* Example:
*
* 1's complement:
* 2's complement: 00110010
- 10000011
---------
10110101
```
- The 2’s comp for the result (10110101) is 01001011 equivalent to (75) 10
Data Representation
- Computers understand on and off states.
- Data is represented in binary form.
- Bit: The basic unit for storing data (0 = off, 1 = on).
- Byte: A group of 8 bits. Each byte has possible values.
- Word: Two bytes (16 bits).
Parity Bit
- Used for error detection.
- Odd parity: The number of 1s is odd.
- Even parity: The number of 1s is even.
Characters Representation
- ASCII (American Standard Code for Information Interchange) is used to represent characters.
- A = 65, B = 66, …, a = 97, b = 98, …
Example using Even Parity
- Represent the character Q (81 in ASCII) in memory using even parity.
- With even parity: D1 (hexadecimal)
Example using Odd Parity
- Represent letters using odd parity:
- A 01000001
- h 01101000
- m 01101101
Integers Representation
- Representing integers in memory using 2 bytes.
- Example: Represent 92
- 0000 0000 01011100
- 0 0 5 C
- Example: Represent -94
- 1’s complement-> 1111111110100001
- 2’s complement-> 1111111110100010
- F F A 2
- Example: Represent 92
Floating Point Representation
32 bits are divided into three sections: sign, exponent, and mantissa.
- 1 bit for sign (0 for positive, 1 for negative).
- 8 bits for exponent.
- 23 bits for mantissa.
For the exponent:
- Range: 0-255. To represent negative exponents, a bias is used.
- Bias = 127 (integer part of 255/2 = 127.5).
- So, the exponent range is -127 to 128.
Example: Represent (26.75)10 using 32-bit floating-point representation.
- Convert to binary:
- Convert to scientific notation:
- Exponent = 127 + 4 = 131. Convert to binary:
- Final representation:
- 0 10000011 10101100000000000000000
- 4 1 D 6 0 0 0 0