C# float bug? 0.1 - 0.1 = 1.490116E-08

后端 未结 5 579
自闭症患者
自闭症患者 2020-12-03 16:23

What\'s going on?! Subtraction works fine until I get to 0.1 - 0.1. I\'m in visual c# 2008 using the nonoba.com API.

Console.WriteLine(\"hit! \" + Users[targ         


        
5条回答
  •  悲哀的现实
    2020-12-03 17:22

    You obviously need to read "What Every Computer Scientist Should Know About Floating Point Numbers".

    Instead of thinking that I've found a bug in situations like this, I usually assume that one of my assumptions needs checking first.

提交回复
热议问题