예제 #1
0
        private void Update(EvaluationContext context)
        {
            var n = Numerator.GetValue(context);
            var d = Denominator.GetValue(context);

            Result.Value = (d == 0) ? 1 : n / d;
        }
예제 #2
0
        protected override MutableObject Mutate(MutableObject mutable)
        {
            foreach (var entry in Operand.GetEntries(mutable))
            {
                var roundType = RoundingType.GetValue(entry);

                var operand = Operand.GetValue(entry);

                var denominator = Denominator.GetValue(entry);

                var outputValue = operand / denominator;

                if (roundType == RoundTypeEnum.Nearest)
                {
                    outputValue = Mathf.Round(outputValue);
                }
                else if (roundType == RoundTypeEnum.Down)
                {
                    outputValue = Mathf.Floor(outputValue);
                }
                else if (roundType == RoundTypeEnum.Up)
                {
                    outputValue = Mathf.Ceil(outputValue);
                }
                else if (roundType == RoundTypeEnum.Truncate)
                {
                    outputValue = (float)Math.Truncate(outputValue);
                }

                outputValue *= denominator;

                NearestTarget.SetValue(outputValue, entry);
            }

            return(mutable);
        }