Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

浮点运算指令的问题 #11

Open
yiranyyu opened this issue Dec 19, 2019 · 1 comment
Open

浮点运算指令的问题 #11

yiranyyu opened this issue Dec 19, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@yiranyyu
Copy link

编译以下程序:
image

得到指令序列如下 (常量表有些问题,不过因为不考量 .s 生成效果,所以还没改):
image

在 win 和 mac 下输出得到:
image

在提供的 docker 中得到:
image

而根据定义 应该得到 nan,也就是说 sign 位是 0

@fazdzz fazdzz added the bug Something isn't working label Dec 19, 2019
@fazdzz
Copy link
Contributor

fazdzz commented Dec 19, 2019

老实说我还是第一次知道 -nan 的存在。虽然 IEEE754 里 nan 的符号位可以是 1 也可以是 0 ,但是这个符号位本身是没有意义的。它都 not a number 了,还有符号真的好怪,不懂为什么标准库会这么玩。

乘法输出的实现都没有做特殊判断,直接用的是operator *(double, double)operator <<(std::ostream&, double)。之后对浮点类型特化一下,加个 isnanisinf 特判一下吧。

顺带一提,测试用例不包含这样的内容。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants