Exemplo n.º 1
0
        public DurationValue Div(NumberValue number)
        {
            double divisor = number.DoubleValue();

            try
            {
                return(Approximate(_months / divisor, _days / divisor, _seconds / divisor, _nanos / divisor));
            }
            catch (ArithmeticException e)
            {
                throw InvalidDurationDivision(this, number, e);
            }
        }
Exemplo n.º 2
0
 public DurationValue Mul(NumberValue number)
 {
     try
     {
         if (number is IntegralValue)
         {
             long factor = number.LongValue();
             return(Duration(Math.multiplyExact(_months, factor), Math.multiplyExact(_days, factor), Math.multiplyExact(_seconds, factor), Math.multiplyExact(_nanos, factor)));
         }
         if (number is FloatingPointValue)
         {
             double factor = number.DoubleValue();
             return(Approximate(_months * factor, _days * factor, _seconds * factor, _nanos * factor));
         }
     }
     catch (ArithmeticException e)
     {
         throw InvalidDurationMultiply(this, number, e);
     }
     throw new InvalidValuesArgumentException("Factor must be either integer of floating point number.");
 }