I have algorithm/computation in Java and unit test for it. The unit test expects result with some precision/delta. Now I ported the algo into .NET and would like to use same uni
Unfortunately there is no way to enforce FP strictness in C#, the .Net CLR just lacks the ability to do calculations with less precision that the maximum that is can.
I think there's a performance gain for this - it doesn't check that you might want less precision. There's also no need - .Net doesn't run in a virtual machine and so doesn't worry about different floating point processors.
However isn't strictfp
optional? Could you execute your Java code without the strictfp
modifier? Then it should pick up the same floating point mechanism as .Net
So instead of forcing .Net to use strictfp
and checking it comes out with the same values as your Java code you could force Java to not use strictfp
and check that it then comes out the same as the .Net code.