Example #1
0
        public Quantity Convert(Unit u)
        {
            var a = Unit.ToBase(amount);

            a = u.FromBase(a);
            return(new Quantity(a, u));
        }
Example #2
0
 private double ConvertTo(double d, Unit u)
 {
     if (ReferenceEquals(null, u))
     {
         return(double.NaN);
     }
     if (!IsSameMeasure(u))
     {
         return(double.NaN);
     }
     d = Unit.ToBase(d);
     return(u.FromBase(d));
 }
Example #3
0
        public Quantity Subtract(Quantity q)
        {
            var u1 = Unit;
            var u2 = q.Unit;

            if (u1.Measure.Name != u2.Measure.Name)
            {
                return(new Quantity());
            }
            var a = Unit.ToBase(amount);

            a = a - q.Unit.ToBase(q.amount);
            return(new Quantity(q.Unit.FromBase(a), q.Unit));
        }