- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 _wtof 时,我没有在小数点右侧得到一位有效数字。这是我的代码:
DOUBLE fVersion = 0.0; // Initialize to zero; confirmed fVersion is 0.00000000000000000
TCHAR sVersion[64] = {0};
_tcscpy_s(sVersion,64,L"1.1");
fVersion = _wtof(sVersion);
使用_wtof后,fVersion是1.1000000000000001,而不是1.1。
谁能解释一下为什么?但最重要的是,如何修复使其只是 1.1?
最佳答案
您无法用二进制 float 准确表示 1/10(十进制)。因此,将会出现错误。
考虑用十进制 float 表示 1/3,最终得到 0.3333333...并且它会永远持续下去,因为这也是不可能的。
典型的推荐阅读是What Every Computer Scientist Should Know About Floating-Point Arithmetic 。确实写得非常好,快来看看吧。
关于c - 即使字符串的精度为一位小数,_wtof 精度也不全为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24697947/
我创建了一个缓冲区,然后在其上创建了一个 Uint8Array,但该数组没有任何值。我希望它具有缓冲区的值。这是一个易于重现的示例: var buf = new ArrayBuffer(32); fo
我正在尝试使用 1D 纹理将整数数组传递到片段着色器中。尽管代码编译并运行,但当我查看着色器中的纹理值时,它们都是零! 这是我在学习了一些教程后得到的 C++ 代码: GLuint texture;
我在 git 中有一个尚未提交的分支,SHA1 0000000000000000000000000000000000000000(全为零),这是正常的还是我损坏了 git 存储库? 请不要回答"is"
我最近提出了一个问题,涉及我在让 MIT Kerberos 与 Microsoft 的 LSA 凭据缓存良好配合时遇到的一些问题。 有人告诉我,设置注册表项 AllowTGTSessionKey 应该
我是一名优秀的程序员,十分优秀!