如何在没有转换指令的情况下将整数乘以 IEEE 双精度?
我正在寻找一个总体想法。我知道 IEEE float 或 double 是如何存储的,但我不知道如何精确地相乘。
我的一个想法是将整数存储为双精度(在浮点寄存器中),然后使用正常的双乘指令。
将 IEEE double 乘以整数时是否有任何特性?就像“你只需乘以指数”或类似的东西?
任何帮助将不胜感激。
I'm looking for a general idea. I know how IEEE float or double is stored, but I don't know how to exactly multiply it.
One idea I have is to store the integer as a double (in float registers) and then use normal double multiply instruction.
Is there any characteristic property when multplying IEEE double by an integer? As in "you have to only multiply the exponent" or something similar?
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需将 n 添加到指数即可将单精度或双精度浮点数乘以 2^n,但对于任何其他乘数值,您也将更改尾数,这显然是不平凡的。
You can multiply a single or double precision float by 2^n just by adding n to the exponent, but for any other multiplier value you'll be changing the mantissa too, and that is obviously going to be non-trivial.
如果您使用的是 x86,则可以使用
FIMUL
指令,它正是您想要的。但当您使用 mips 时,对于一般情况,您没有比转换和乘法更好的方法了。If you were on x86, you could use the
FIMUL
instruction, which does exactly what you want. But as you are on mips, you have no better way than converting and multiplying for the general case.