为什么C#允许*隐含的*从龙转换为浮动,这时候可能会失去precision?可能会、转换为、这时候、precision

由网友(落尘)分享简介:有一个类似的问题隆中浮动,为什么呢?这里没有回答什么,我搜索为A similar question Long in Float, why? here does not answer what I am searching for.C#标准允许从长期隐式转换为浮动。但是,任何长期大于2 ^ 24时psented为fl...

有一个类似的问题隆中浮动,为什么呢?这里没有回答什么,我搜索为

A similar question Long in Float, why? here does not answer what I am searching for.

C#标准允许从长期隐式转换为浮动。 但是,任何长期大于2 ^ 24时psented为float再$ P $势必会失去其价值。 C#标准中明确指出,长时间浮充转换可能失去'precision,但绝不会输的幅度。

C# standard allows implicit conversion from long to float. But any long greater than 2^24 when represented as a float is bound to lose its 'value'. C# standard clearly states that long to float conversion may lose 'precision' but will never lose 'magnitude'.

在参考整数类型是什么'precision'和'规模'的意思。是不是数n,从数n + 1不同的实数,其中3.333333和3.333329可被视为足够接近的计算(即取决于什么precision程序员希望)完全不同 是不是允许从长期隐式转换为浮动邀请微妙的错误,因为它会导致一个长的默默失去价值(如C#程序员,我习惯了编译器做了出色的工作在守着我对这样的问题)

那么,什么可能是C#语言设计团队的理念在允许这种转换是隐式的?它是什么,我在这里失踪的证明,从长期隐式转换为浮动?

So what could have been the rationale of C# language design team in allowing this conversion as implicit? What is it that I am missing here that justifies implicit conversion from long to float?

推荐答案

在一般情况下,浮点数不再present多的数字完全相同。就其性质而言,他们是不准确的,如有precision错误。这真的不增加价值要提醒你的是始终与浮点运算的情况。

In general, floating point numbers don't represent many numbers exactly. By their nature they are inexact and subject to precision errors. It really doesn't add value to warn you about what is always the case with floating point.

阅读全文

相关推荐

最新文章