Example #1
0
        /// <summary>
        /// renders the entered number and adjusts the font size by the number of digits
        /// </summary>
        /// <param name="number">Number to render on display</param>
        private void show_number(double number)
        {
            display.FontSize = 36;
            display.Text     = "" + number;

            if (display.Text.Length > 30)
            {
                display.Text = "" + dispString_to_numb(display.Text).ToString("e");
            }

            if (display.Text.Length > 17)
            {
                display.FontSize = 36 * Math.Pow(0.95, display.Text.Length - 17.0);
            }
        }
Example #2
0
        public void PowTest()
        {
            Assert.AreEqual(0, math.Pow(0, 42));
            Assert.AreEqual(1, math.Pow(42, 0));
            Assert.AreEqual(1, math.Pow(1, 42));
            Assert.AreEqual(1, math.Pow(-1, 42));
            Assert.AreEqual(-1, math.Pow(-1, 41));
            Assert.AreEqual(36, math.Pow(6, 2));
            Assert.AreEqual(1000, math.Pow(10, 3));
            Assert.AreEqual(100000000, math.Pow(100000000, 1));
            Assert.AreEqual(1024, math.Pow(2, 10));
            Assert.AreEqual(59049, math.Pow(-3, 10));
            Assert.AreEqual(15.625, math.Pow(2.5, 3), Exactness);

            /// <summary> NaN result</summary>
            string noFailMessage = "No exception message when result was NaN.";

            try
            {
                math.Pow(-1, 0.5);
                Assert.Fail(noFailMessage);
            }
            catch (Exception)
            {
            }
            try
            {
                math.Pow(0, -1);
                Assert.Fail(noFailMessage);
            }
            catch (Exception)
            {
            }
        }