---
# System prepended metadata

title: Lab x

---

# Lab 7
Name: Atreya M
Roll No.: CS22B009

---
## Question 1

0.1 * 2 = 0.2 ⇒ 0
0.2 * 2 = 0.4 ⇒ 0
0.4 * 2 = 0.8 ⇒ 0
0.8 * 2 = 1.6 ⇒ 1
0.6 * 2 = 1.2 ⇒ 1
0.2 * 2 = 0.4 ⇒ 0
0.4 * 2 = 0.8 ⇒ 0
0.8 * 2 = 1.6 ⇒ 1
0.6 * 2 = 1.2 ⇒ 1
....

0.1 in binary does not terminate, i.e, 0.1 in binary would be represented as 0.0001100110011... (repeating).


---
## Question 2

The fractional part of 0.1 in binary will be 0.0001100110011... (repeating).

Since the binary fraction starts with 0.0001 (1/16), we can normalize it by shifting the radix point to the right, effectively multiplying by 2 until the leading digit is 1. This gives us 1.1001100110011....

=> **Sign Bit:** The sign bit will be 0 for positive                    numbers.

=> **Exponent:** The exponent is the position of the radix              point after normalization. In this case,              it's 01111011, as we shifted the radix                point 4 positions to the right.

=> **Mantissa:** The mantissa is the fractional part after              normalization, excluding the leading 1.                In this case, it's 1001100110011...                    (which repeats).

Hence,
Sign bit: 0 (positive)
Exponent: 01111011 (127 + 4 = 131 in decimal)
Mantissa: 10011001100110011001101 (repeating)


---
## Question 3

0.2 * 2 = 0.4 ⇒ 0
0.4 * 2 = 0.8 ⇒ 0
0.8 * 2 = 1.6 ⇒ 1
0.6 * 2 = 1.2 ⇒ 1
0.2 * 2 = 0.4 ⇒ 0
0.4 * 2 = 0.8 ⇒ 0
0.8 * 2 = 1.6 ⇒ 1
... (repeating)

The binary representation of 0.2 would be: 0.001100110011001100110011... (repeating)

Since the binary fraction starts with 0.0011 (3/16), we can normalize it by shifting the radix point to the right, effectively multiplying by 2 until the leading digit is 1. This gives us 1.100110011001100110011... (repeating).

Sign Bit: The sign bit will be 0 for positive numbers. 

Exponent: The exponent is the position of the radix point after normalization. In this case, it's 01111100 (127 + 2 = 129 in decimal). 

Mantissa: The mantissa is the fractional part after normalization, excluding the leading 1. In this case, it's 10011001100110011001101... (repeating).

binary representaion: 0 01111100 10011001100110011001101...

**Convert IEEE 754 Representation back to Decimal:**

Exponent: 01111100 (129 in decimal) - 127 = 2
Mantissa: 1.100110011001100110011... (repeating)
Decimal value = (-1)^0 * 1.100110011001100110011... * 2^2

= 1.100110011001100110011... * 4

≈ 0.199999988079071044921875

So, when converted back to decimal, the value will be close to 0.2 but not exactly 0.2 due to the limitations of floating-point representation.



---
## Question 4

we represent each floating-point number as a pair of numbers: one for the integer part and one for the fractional part.

**rules:**

1) Represent each floating-point number as a pair of integers: one for the integer part and one for the fractional part.
2) Add the iRepresent each floating-point number as a pair of integers: one for the integer part and one for the fractional part.
3) Add the fractional parts of both numbers.
4) If the sum of the fractional parts exceeds 1, carry over to the integer part.
5) Combine the integer and fractional parts to get the result.

**addition of 5.391 and 3.012 using this approach:**

5.391:
Integer part: 5
Fractional part: 0.391
3.012:
Integer part: 3
Fractional part: 0.012

Integer part: 5 + 3 = 8
Fractional part: 0.391 + 0.012 = 0.403

result is 9.403.








---
## Question 5

```assembly=
flw f0, 0(a0)
flw f1, 0(a1)
fadd.s f2, f0, f1
fsw f2, 0(a2)
```

---



