【问题标题】:Rounding double precision floats in MIPS在 MIPS 中舍入双精度浮点数
【发布时间】:2015-06-12 17:55:12
【问题描述】:

我正在尝试将双精度浮点数舍入到 MIPS 中最接近的 int。

这是我的代码。

li $v0, 7
syscall
round.w.d $f2, $f0

输入 10.5 后,四舍五入为 10.500000000000018。这个 round.w.d 函数应该将 f0 寄存器四舍五入到最接近的 32 位 int (.word),然后将结果存储在 f2 中。我究竟做错了什么?我找不到任何表明程序不正确的信息。 提前感谢您的帮助。

【问题讨论】:

    标签: assembly mips mars-simulator


    【解决方案1】:
    li $v0, 7
    syscall
    round.w.d $f2, $f0
    cvt.d.w $f2, $f2 <--- this fixed the problem. 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-23
      • 2018-07-06
      • 1970-01-01
      相关资源
      最近更新 更多