VS 2015 for x86-32,虽然我从.NET 2003开始就看到了这个问题。
我想知道为什么没有解决这个问题:
#include <cfenv>
#include <cmath>
int main(int argc, char **argv)
{
fesetround(FE_DOWNWARD);
auto y_lo = sin(1.0); // y_lo = 0.84147098480789650
fesetround(FE_UPWARD);
auto y_hi = sin(1.0); // y_hi = (same)
// y_hi SHOULD BE 0.84147098480789662
return 0;
}
单步执行sin
的dissasembly会显示它在执行fsin
之前重置舍入模式(为什么?)。除了手工重写所有库函数外,可以采取哪些措施来解决这个问题呢?
以下是cmp
在[esp]
检查已保存的控制字的有问题的call
- 在此之前没有任何幻想,只有cmp word ptr [esp],27Fh ; WTF? Why force a default here?
。
#include "stdafx.h"
#include <iostream>
#include <Windows.h>
using namespace std;
const int width = 12;
const int height = 25;
char bucket [width][height] ={"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x"," "," "," "," "," "," "," "," "," "," ","x",
"x","x","x","x","x","x","x","x","x","x","x","x",
};
void setCursorTo(int x, int y){
HANDLE handle;
COORD position;
handle = GetStdHandle(STD_OUTPUT_HANDLE);
position.X = x;
position.Y = y;
SetConsoleCursorPosition(handle, position);
}
int _tmain(int argc, _TCHAR* argv[])
{
setCursorTo(0,0);
cout<<bucket<<endl;
return 0;
}enter code here
所以,AFAIK,这片小小的辉煌(或类似的东西)已经在CRT中恶化了至少12年。没人注意到这个吗?我无法找到或想象任何合理的理由背后。