public static NumericValue Multiply(NumericValue left, NumericValue right)
        {
            var decomposer = new UnitOfMeasureDecomposer();
            var leftComponents = decomposer.GetComponents(left.UnitOfMeasure.ToInternalUom(), 1);
            var rightComponents = decomposer.GetComponents(right.UnitOfMeasure.ToInternalUom(), 1);
            var allComponents = leftComponents.Union(rightComponents).ToList();

            return new UnitOfMeasureComponentSimplifier().Simplify(allComponents, left.Value * right.Value);
        }
Example #2
0
        public static NumericValue Multiply(NumericValue left, NumericValue right)
        {
            var decomposer      = new UnitOfMeasureDecomposer();
            var leftComponents  = decomposer.GetComponents(left.UnitOfMeasure.ToInternalUom(), 1);
            var rightComponents = decomposer.GetComponents(right.UnitOfMeasure.ToInternalUom(), 1);
            var allComponents   = leftComponents.Union(rightComponents).ToList();

            return(new UnitOfMeasureComponentSimplifier().Simplify(allComponents, left.Value * right.Value));
        }
Example #3
0
      public static NumericValue Divide(NumericValue numerator, NumericValue denominator)
      {
         if (denominator.Value == 0.0)
            throw new DivideByZeroException();

         var decomposer = new UnitOfMeasureDecomposer();
         var numeratorComponets = decomposer.GetComponents(numerator.UnitOfMeasure.ToInternalUom(), 1);
         var denominatorComponents = decomposer.GetComponents(denominator.UnitOfMeasure.ToInternalUom(), -1);
         var allComponents = numeratorComponets.Union(denominatorComponents).ToList();
         return new UnitOfMeasureComponentSimplifier().Simplify(allComponents, numerator.Value / denominator.Value);
      }
Example #4
0
        public static NumericValue Divide(NumericValue numerator, NumericValue denominator)
        {
            if (denominator.Value == 0.0)
            {
                throw new DivideByZeroException();
            }

            var decomposer            = new UnitOfMeasureDecomposer();
            var numeratorComponets    = decomposer.GetComponents(numerator.UnitOfMeasure.ToInternalUom(), 1);
            var denominatorComponents = decomposer.GetComponents(denominator.UnitOfMeasure.ToInternalUom(), -1);
            var allComponents         = numeratorComponets.Union(denominatorComponents).ToList();

            return(new UnitOfMeasureComponentSimplifier().Simplify(allComponents, numerator.Value / denominator.Value));
        }