3

Sorry if this is a repeat, but this is killing me and most of the .NET 4.0 vs 4.5 articles I find degenerate into screaming contests so I figured I would ask here.

Basically did they make any changes to floating point arithmetic from .NET 4.0 to 4.5?

To expound, we have a (mostly) C# application that stores coordinates in 3 dimensions as floats and performs some sine and cosine operations on them. I can't be too specific for business reasons and lack of access to source code. We compiled it in Visual Studio 2010 SP 1 using .NET 4.0 and developed automated unit tests for this compilation and they all passed. After installing 2012, some of the unit tests were failing based on precision of floating point variables. We are losing something like 6 digits off of our expected results according to our logs. Our current hypothesis is that the register size change from 86 bits to 64 bits has something to do with it, but the fact that the unit tests are breaking in both 2010 and 2012 leads us to believe that it has something to do with one of the hidden bug fixes in .NET 4.5. I am at the end of my rope and have been hitting my head against this problem for at least 3 days and two of my coworkers have been working it for longer.

Thanks guys. Hopefully I have given enough information.

Jake
  • 328
  • 2
  • 14
  • It would be very helpful if you could boil this down to a specific example calculation that yields this large difference. Otherwise we'll just be guessing blind! – Baldrick May 14 '14 at 13:40
  • Might be helpful to post an example of such a calculation that can be rrplicated easily by the community. You could also make an inquiry of the same on the Microsoft MSDN forums in the .net forums. – Mike Dinescu May 14 '14 at 13:40
  • I'm doubtful that something so fundamental would change. It might be a good candidate for http://blog.coverity.com/category/ask-the-bug-guys – itsme86 May 14 '14 at 13:47
  • 2
    I don't know your specific and neither I know .NET 4.5 changes in so much details, but I really don't believe that sugh a huge change might be done in floating point arithmetics. it hasn't been changed for at least 20 years already and there are standards which describe how it should work - it isn't the thing that could be changed easily by the will of some developer or team, even at Microsoft. You better search for the bug in your tests. Maybe you rely on some precision loss during floating values calculation etc. – Sasha May 14 '14 at 13:47
  • I'll work on that. We're going to step through our test procedures to figure out what equation is breaking as soon as we can. Unfortunately strictly controlled systems and one systems admin for a huge number of systems is creating a bottle neck. – Jake May 14 '14 at 13:48
  • 3
    Try to invoke Eric Lippert : see http://stackoverflow.com/questions/8795550/casting-a-result-to-float-in-method-returning-float-changes-result , some interesting relations between machine / runtime / effect on floating points... Could be the same case : jitter 4.0 choosed to go to higher precision, while 4.5 choosed not to. – Raphaël Althaus May 14 '14 at 13:52
  • Thanks Raphael. I think that is going to work. Found out our test installs got pushed back until at least tomorrow. Looks like, for now, we're just going to stick with 2010 and test 2012 at a later date, since we have to make the decision today. – Jake May 14 '14 at 14:15
  • @Jake I know that this is a pretty old post, but did you ever come to a resolution? – d.moncada Aug 24 '16 at 17:13

0 Answers0