Esempio n. 1
0
        public NumericalValue division(NumericalValue other)
        {
            assertAssignment();
            //
            dynamic other_value = other.getValue();

            Debugging.assert(other_value != 0, new AquilaExceptions.ZeroDivisionException($"{numeric_value} / {other_value}"));
            dynamic result_raw_value = numeric_value / other_value;
            bool    result_is_const  = is_const && other.isConst();
            // source variables
            var source_variables = new Dictionary <string, NumericalValue>();

            if (!string.IsNullOrEmpty(getName()))
            {
                source_variables.Add(getName(), this);
            }
            if (!string.IsNullOrEmpty(other.getName()) && other.getName() != getName())
            {
                source_variables.Add(other.getName(), other);
            }
            source_variables = mergeDictionaries(source_variables, other.source_vars);
            //
            NumericalValue result = Activator.CreateInstance(_val_type, result_raw_value, result_is_const, source_variables) as NumericalValue;

            return(result);
        }
Esempio n. 2
0
        public NumericalValue mult(NumericalValue other)
        {
            assertAssignment();
            //
            dynamic result_raw_value = numeric_value * other.getValue();
            bool    result_is_const  = is_const && other.isConst();
            // source variables
            var source_variables = new Dictionary <string, NumericalValue>();

            if (!string.IsNullOrEmpty(getName()))
            {
                source_variables.Add(getName(), this);
            }
            if (!string.IsNullOrEmpty(other.getName()) && other.getName() != getName())
            {
                source_variables.Add(other.getName(), other);
            }
            source_variables = mergeDictionaries(source_variables, other.source_vars);
            //
            NumericalValue result = Activator.CreateInstance(_val_type, result_raw_value, result_is_const, source_variables) as NumericalValue;

            return(result);
        }