Floating Point Analysis MIPS Updated
Floating Point Analysis MIPS Updated
Question 1:
Analyze the value of the bit pattern 0x0C000000 if it represents a floating-point number in
IEEE 754 single-precision format.
Question 2:
Analyze how the decimal number 63.25 is represented as a floating-point number in IEEE
754 single-precision format.
Question 3:
Analyze the floating-point representation of -1024.75 in IEEE 754 single-precision format.
Question 4:
Analyze the decimal value represented by the bit pattern 0xC1A40000 in IEEE 754 single-
precision format.
Question 5:
Analyze the IEEE 754 single-precision binary representation for the decimal number 250.5.
Question 7:
Analyze how the IEEE 754 double-precision format encodes the decimal number 3.14.
Provide the bit pattern.
Question 8:
Analyze how 0x3FD8000000000000 is represented in IEEE 754 double-precision format.
What decimal number does it correspond to?
Question 9:
Analyze the IEEE 754 double-precision representation for -0.001953125. Provide both the
binary and hexadecimal representations.
Question 10:
Refer to the provided MIPS program implementation and analysis for Question 10.
Question 11:
Refer to the provided MIPS program implementation and analysis for Question 11.
Question 12:
Refer to the provided MIPS program implementation and analysis for Question 12.
Question 13:
Refer to the provided MIPS program implementation and analysis for Question 13.
MIPS Code:
```asm
.data
num1: .float 5.5 # First number
num2: .float 3.2 # Second number
greater_msg: .asciiz "Num1 is greater than Num2\n"
less_msg: .asciiz "Num1 is less than Num2\n"
equal_msg: .asciiz "Num1 is equal to Num2\n"
.text
.globl main
main:
# Load the two numbers
lwc1 $f0, num1 # Load num1 into $f0
lwc1 $f2, num2 # Load num2 into $f2
less_label:
la $a0, less_msg # Load address of less_msg
li $v0, 4 # Print string syscall
syscall
j end # Jump to end
equal_label:
la $a0, equal_msg # Load address of equal_msg
li $v0, 4 # Print string syscall
syscall
end:
li $v0, 10 # Exit syscall
syscall
```
**Expected Output**:
- If `num1 = 5.5` and `num2 = 3.2`, the output will be: "Num1 is greater than Num2".
- Modify `num1` and `num2` to test other conditions.
Question 11: Find the maximum of two double-precision floating-point numbers
MIPS Code:
```asm
.data
num1: .double 7.5 # First double-precision number
num2: .double 10.3 # Second double-precision number
max_result: .double 0.0 # To store the maximum value
.text
.globl main
main:
# Load the two numbers
ldc1 $f0, num1 # Load num1 into $f0-$f1
ldc1 $f2, num2 # Load num2 into $f2-$f3
second_is_max:
sdc1 $f2, max_result # Store num2 in max_result
end:
li $v0, 10 # Exit syscall
syscall
```
**Expected Output**:
- For `num1 = 7.5` and `num2 = 10.3`, the value in `max_result` will be `10.3`. Change the
inputs to test other cases.
Question 12: Compare the absolute values of two single-precision floating-point numbers
MIPS Code:
```asm
.data
num1: .float -5.3 # First number
num2: .float 4.2 # Second number
greater_msg: .asciiz "Absolute value of Num1 is greater\n"
less_msg: .asciiz "Absolute value of Num1 is less\n"
equal_msg: .asciiz "Absolute values are equal\n"
.text
.globl main
main:
# Load the two numbers
lwc1 $f0, num1 # Load num1 into $f0
lwc1 $f2, num2 # Load num2 into $f2
greater_label:
la $a0, greater_msg # Load greater message
li $v0, 4 # Print string
syscall
j end
less_label:
la $a0, less_msg
li $v0, 4
syscall
j end
equal_label:
la $a0, equal_msg
li $v0, 4
syscall
end:
li $v0, 10 # Exit
syscall
```
**Expected Output**:
- Adjust array or threshold values to test the program's behavior.
Question 13: Count how many single-precision floating-point numbers in an array are greater
than a threshold of 3.0
MIPS Code:
```asm
.data
array: .float 1.2, 4.5, 2.9, 5.6, 3.1, 7.3, 2.5, 8.9, 1.1, 4.0
threshold: .float 3.0
count: .word 0
.text
.globl main
main:
# Initialize variables
la $t0, array # Load array address
li $t1, 10 # Array size
lwc1 $f2, threshold # Load threshold into $f2
li $t2, 0 # Counter for numbers greater than threshold
loop:
beq $t1, $zero, done # Exit loop if all elements are checked
skip_increment:
addiu $t1, $t1, -1 # Decrement array size
j loop
done:
sw $t2, count # Store result in count
li $v0, 10 # Exit syscall
syscall
```
**Expected Output**:
- Adjust array or threshold values to test the program's behavior.