tags:

views:

355

answers:

1

I am not sure how to print out a floating point single with one decimal place.

I get '88.09999847' instead of '88.1'. Please advise

For example: if I have register $f10 = '88.09999847'

mov.s   $f12, $f10

li  $v0, 2 

syscall

I get output as "88.09999847"

How do I round up to one decimal place and print out "88.1"

Any help would be appreciated

A: 

1) Multiply the number by 10 (since you're rounding to one decimal place.)
2) Push the number to the stack (or appropriate register.)
3) Round is a system call (on my machine, the code is call roundf)
4) Divide the result by 10

Yohnny