If I had the floating point (saved in some $f register) 1684.714 how could I round that to 1684.71? If I had the floating point 1684.716, how could I round that to 1684.72?
Asked
Active
Viewed 916 times
1 Answers
0
Supposing you are using $f0:
addi $t0, $s0, 100 ; t0 = 100
mult $f0, $t0 ; LO = f0*100
mflo $f1 ; f1 = LO
round.w.s $f1, $f1 ; f1 = round(f1)
mfc1 $t1, $f1 ; t1 = f1
div $t1, $t0 ; LO = t1/100
mflo $t2 ; t2 = LO
$t2 has the rounded value.

Yago Tomé
- 46
- 4
-
You should write comments in the code to help readers understand the code better. – Amit Chahar Mar 27 '18 at 13:51
-
Wouldn't this just round it to an integer? Sorry if I am misunderstanding. I am asking how to round to the nearest hundredths place. – Danny Mullen Mar 27 '18 at 16:10
-
`mult $f0, $t0` is not a MIPS instruction. – markgz Mar 27 '18 at 17:40