From 836fa01e1b8aaa3d6dab28aceba9cad4dbfdb5e9 Mon Sep 17 00:00:00 2001 From: billran Date: Tue, 29 Dec 2020 15:10:21 -0800 Subject: [PATCH] Fixed troy ounce conversion issue. Fixed SI peta name. --- CaliperSharp/MeasurementSystem.cs | 2 +- CaliperSharp/Prefix.cs | 2 +- CaliperSharp/bin/Release/CaliperSharp.dll | Bin 61440 -> 61440 bytes CaliperSharpTests/TestBridges.cs | 16 ++++++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CaliperSharp/MeasurementSystem.cs b/CaliperSharp/MeasurementSystem.cs index 0bec177..b734c0f 100644 --- a/CaliperSharp/MeasurementSystem.cs +++ b/CaliperSharp/MeasurementSystem.cs @@ -887,7 +887,7 @@ private UnitOfMeasure CreateCustomaryUnit(Unit unit) // troy ounce uom = CreateScalarUOM(UnitType.MASS, Unit.TROY_OUNCE, UnitsManager.GetString("troy_oz.name"), UnitsManager.GetString("troy_oz.symbol"), UnitsManager.GetString("troy_oz.desc")); - uom.SetConversion(31.1034768, GetUOM(Unit.GRAM)); + uom.SetConversion(0.06857142857, GetUOM(Unit.POUND_MASS)); break; case Unit.SLUG: diff --git a/CaliperSharp/Prefix.cs b/CaliperSharp/Prefix.cs index 2ee2d51..dd438ca 100644 --- a/CaliperSharp/Prefix.cs +++ b/CaliperSharp/Prefix.cs @@ -41,7 +41,7 @@ public class Prefix /// SI prefix 10^18 public static readonly Prefix EXA = new Prefix("exa", "E", 1.0E+18); /// SI prefix 10^15 - public static readonly Prefix PETA = new Prefix("petta", "P", 1.0E+15); + public static readonly Prefix PETA = new Prefix("peta", "P", 1.0E+15); /// SI prefix 10^12 public static readonly Prefix TERA = new Prefix("tera", "T", 1.0E+12); /// SI prefix 10^9 diff --git a/CaliperSharp/bin/Release/CaliperSharp.dll b/CaliperSharp/bin/Release/CaliperSharp.dll index 493708a0693503a36a7adfc3f6dc834d4fd9e865..75d74ac9e9b970706828e7243c87d48c976f3145 100644 GIT binary patch delta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aliperSharpTests/TestBridges.cs @@ -221,5 +221,21 @@ public void TestBridgeUnits2() } } + + [TestMethod] + public void TestBridgeUnits3() + { + UnitOfMeasure uomGrams = sys.GetUOM(Unit.GRAM); + UnitOfMeasure uomTonnes = sys.GetUOM(Unit.TONNE); + UnitOfMeasure uomShortTons = sys.GetUOM(Unit.US_TON); + UnitOfMeasure uomTroyOz = sys.GetUOM(Unit.TROY_OUNCE); + UnitOfMeasure uomPennyweight = sys.CreateScalarUOM(UnitType.MASS, "pennyweight", "dwt", "Pennyweight"); + uomPennyweight.SetConversion(0.05, uomTroyOz); + UnitOfMeasure uomGramsPerTonne = sys.CreateQuotientUOM(uomGrams, uomTonnes); + UnitOfMeasure uomPennyweightPerShortTon = sys.CreateQuotientUOM(uomPennyweight, uomShortTons); + Quantity grade = new Quantity(0.95, uomGramsPerTonne); + Quantity converted = grade.Convert(uomPennyweightPerShortTon); + Assert.IsTrue(IsCloseTo(converted.Amount, 0.554167, DELTA6)); + } } }