Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 9db3c767 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

Corrected Error in SI Unit Division

parent a7ef82da
No related branches found
No related tags found
No related merge requests found
......@@ -378,6 +378,11 @@ namespace TUGraz.VectoCore.Utils
return new SI(si1._value * d, si1);
}
public static SI operator *(double d, SI si1)
{
return new SI(d * si1._value, si1);
}
public static SI operator /(SI si1, double d)
{
return new SI(si1._value / d, si1);
......@@ -385,7 +390,7 @@ namespace TUGraz.VectoCore.Utils
public static SI operator /(double d, SI si1)
{
return si1 / d;
return new SI(d / si1._value, si1);
}
public static bool operator <(SI si1, SI si2)
......
......@@ -25,7 +25,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CodeAnalysisIgnoreGeneratedCode>true</CodeAnalysisIgnoreGeneratedCode>
<CodeContractsEnableRuntimeChecking>True</CodeContractsEnableRuntimeChecking>
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
......
......@@ -52,6 +52,20 @@ namespace TUGraz.VectoCore.Tests.Utils
Assert.AreEqual(5000, (double)kg);
Assert.AreEqual("5000 [g]", kg.ToString());
var x = 5.SI();
Assert.AreEqual((2.0 / 5.0).SI(), 2 / x);
Assert.AreEqual((5.0 / 2.0).SI(), x / 2);
Assert.AreEqual((2.0 * 5.0).SI(), 2 * x);
Assert.AreEqual((5.0 * 2.0).SI(), x * 2);
Assert.AreEqual((2.0 / 5.0).SI(), 2.0 / x);
Assert.AreEqual((5.0 / 2.0).SI(), x / 2.0);
Assert.AreEqual((2 * 5).SI(), 2.0 * x);
Assert.AreEqual((5 * 2).SI(), x * 2.0);
var y = 2.SI();
Assert.AreEqual((2 * 5).SI(), y * x);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment