Detect if floating point number is too big (overflow)

340 Views Asked by At

I'm starting with MIPS and have been assigned a homework in which I have to find the hypotenuse of a triangle given its legs (all of them are single precision floating point numbers). However, in every step I have to check for overflow, by comparing the number with the IEEE754 representation for "infinite", but I don't know how to do that, and I would appreciate any help.

Edit: only code I have so far is for the inputs.

.text
main:
in1:    li $v0,4            #
        la $a0,inleg1       #message to request leg 1
        syscall             #
        li $v0,6            #read entered value as float
        syscall
        mov.s $f1,$f0       #move read value --> $f1=leg1

    #So now I have to include a condition to detect overflow, and show an error message and request the number again
    #The idea is to compare $f1 with infinity, and if it's not smaller, we have overflow
    #Then I have to repeat the evaluation after every operation performed
0

There are 0 best solutions below