Example #1
0
        public void CustomFunctionMultipleVar()
        {
            var x   = new UncertainNumber(5, 2);
            var y   = new UncertainNumber(5, 1);
            var num = UncertainNumber.CustomFunction(d => d[0] * d[1], x, y);

            Assert.AreEqual((int)num.Value, 25);

            // NOTE: 15.0000000000001 is too accurate, should be simplified to just 15
            Assert.AreEqual(num.Uncertainty, (decimal)15.0000000000001);
        }
Example #2
0
        public void CustomFunctionOneVar()
        {
            var x = new UncertainNumber(5, 2);

            x = x.CustomFunction(d => d * d);

            Assert.AreEqual((int)x.Value, 25);

            // NOTE: 20.0000000000002 is too accurate, should be simplified to just 15
            Assert.AreEqual(x.Uncertainty, (decimal)20.0000000000002);
        }
        protected void CalculateButton_Click(object sender, EventArgs e)
        {
            if (functionInput.Text == "")
            {
                return;
            }

            try
            {
                var watch = new Stopwatch();
                watch.Start();

                TableOutput.InnerText =
                    UncertainNumber.ConvertArrayToTsvString(
                        UncertainNumber.AutoFormat(UncertainNumber.CustomFunction(Func, tableInput.InnerText)));

                watch.Stop();
                ElapsedTimeLabel.Text = string.Format("Elapsed time: {0} ms", watch.Elapsed.TotalMilliseconds);
            }
            catch
            {
                TableOutput.InnerText = "Something went wrong. Check so that you've entered the function correctly.";
            }
        }