Is “(float)integer == integer” guaranteed to be equal in C#?

前端 未结 5 2066
有刺的猬
有刺的猬 2021-01-07 20:05

While \"we all know\" that x == y can be problematic, where x and y are floating point values, this question is a bit more specific:

5条回答
  •  太阳男子
    2021-01-07 20:41

    My understanding of floating point arithmetic calculations is that they are handled by the CPU, which solely determines your precision. Therefore there is no definite value above which floats lose precision.

    I had thought that the x86 architecture, for instance, guaranteed a minimum, but I've been proven wrong.

提交回复
热议问题