C# .Net double issue… 6.8 != 6.8?

后端 未结 3 391
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 05:20

I was doing some unit testing at work and a peculiar error popped up for one of the assertions. Note that expectedValue and actualValue are both doubles.

Ass         


        
3条回答
  •  迷失自我
    2021-01-15 06:00

    You could convert both to a string : actualValue.ToString("0.000") and compare those strings.

    That could be made to match your requirements closely.

提交回复
热议问题