检测浮点数是否过大(溢出)

时间:2017-05-22 09:42:56

标签: floating-point overflow mips ieee-754 single-precision

我从MIPS开始,已经分配了一个作业,我必须在其中找到三角形的斜边(所有这些都是单精度浮点数)。但是,在每一步中我都要检查是否有溢出,将数字与IEEE754表示进行比较"无限",但我不知道如何做到这一点,我将不胜感激任何帮助。

编辑:到目前为止,我只有输入的代码。

.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 个答案:

没有答案