为什么 MSTest 向导使用双打的 F 后缀而不是 D?

发布于 2024-07-14 00:32:30 字数 206 浏览 3 评论 0原文

当我使用 MS Visual Studio 的内置单元测试向导创建测试时,它会创建如下所示的代码:

double number = 0F;

在 C# 中,“F”代表浮点型、与大小写无关,“D”代表双精度型。 使用“F”后缀而不是“D”会导致精度丢失。

如果是错误,我可以在哪里向 Microsoft 报告?

When I create a test using MS Visual Studio's builtin unit test wizard it creates code with lines like the below:

double number = 0F;

In C# "F" stands for float, case-independent, and "D" for double. Using "F" suffix instead of "D" leads to precision lost.

If it's a bug, where can I report it to Microsoft?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

瞄了个咪的 2024-07-21 00:32:30

我不明白这怎么可能只是一个错误。 在这种情况下完全无害,但仍然是一个错误。 您可以使用 Connect 报告此类情况。 然而,我已经清除了比这更重要的错误,所以我不期望采取太多行动。

I don't see how that could be anything but a bug. Completely harmless in this case, but still a bug. You can use Connect to report this kind of thing. However, I've had much more important bugs swept aside than this so I wouldn't expect much action.

惜醉颜 2024-07-21 00:32:30

如果该值始终为 0F,则根本不会丢失任何信息。

一般来说,任何浮点数都可以转换为双精度数,而不会损失精度(假设是 IEEE 754)。

只要测试值不需要截断来表示为浮点数,那么正确性就没有问题。 最终用户感到困惑以及想要修改值时增加的麻烦仍然是一个问题。

If the value is always 0F then no information will be lost at all.

In general any float can be converted to a double with no loss of precision (IEEE 754 assumed).

So long as the test value has not needed truncation to be represented as a float then there is no problem with regards to correctness. The confusion to end users and increased hassle when wanting to modify the values is still a problem.

绝不服输 2024-07-21 00:32:30

如果您使用十进制(M 后缀),那么您不必担心它有估计错误或精度损失。

If you use a Decimal (M suffix) then you don't have to worry about it having estimation errors or precision loss.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文