public void MathLibraryMul()
        {
            var sut = new Matho();

            Assert.AreEqual(sut.Mul(3, 5), 15);
            Assert.AreEqual(sut.Mul(-7, 1897), -13279);
            Assert.AreEqual(sut.Mul(8.245, 5.240), 43, 2038);
            Assert.AreEqual(sut.Mul(456789, 456789), 208656190521);
        }
Esempio n. 2
0
        /**
         * Funkcia spracuvajúca výsledok operácií kalkulačky
         *
         * @return double výsledok zadanej operácie, respektíve iba číslo ak nebola zadaná žiadna operácia
         */
        private double operation_result()
        {
            try
            {
                if (actual_sign == sign.add)
                {
                    return(matho.Add(result, output_handle.get_num_on_display()));
                }
                if (actual_sign == sign.sub)
                {
                    return(matho.Sub(result, output_handle.get_num_on_display()));
                }
                if (actual_sign == sign.mul)
                {
                    return(matho.Mul(result, output_handle.get_num_on_display()));
                }
                if (actual_sign == sign.div)
                {
                    return(matho.Div(result, output_handle.get_num_on_display()));
                }
                if (actual_sign == sign.mod)
                {
                    return(matho.Mod(result, output_handle.get_num_on_display()));
                }
                if (actual_sign == sign.fac)
                {
                    return(matho.Fakt(output_handle.get_num_on_display()));
                }
                if (actual_sign == sign.sqr)
                {
                    return(matho.SquareRoot(output_handle.get_num_on_display()));
                }
                if (actual_sign == sign.root_3)
                {
                    return(matho.ThirdRoot(output_handle.get_num_on_display()));
                }
                if (actual_sign == sign.pow_2)
                {
                    return(matho.Pow(output_handle.get_num_on_display(), 2));
                }
                if (actual_sign == sign.pow_y)
                {
                    return(matho.Pow(result, output_handle.get_num_on_display()));
                }

                return(output_handle.get_num_on_display());
            }

            catch (ArgumentOutOfRangeException)
            {
                output_handle.clear_log();
                output_handle.clear_display();
                if (actual_sign == sign.fac)
                {
                    output_handle.print_on_display("Factorial cannot be decimal or < 1!");
                }
                if (actual_sign == sign.pow_y)
                {
                    output_handle.print_on_display("Exponent cannot be decimal or < 1!");
                }
                if (actual_sign == sign.sqr)
                {
                    output_handle.print_on_display("Square root of x cannot b < 0!");
                }
                if (actual_sign == sign.root_3)
                {
                    output_handle.print_on_display("Cubic root of x cannot b < 0!");
                }
                throw;
            }

            catch (DivideByZeroException)
            {
                output_handle.clear_log();
                output_handle.clear_display();
                output_handle.print_on_display("Cannot divide by zero!");
                throw;
            }
        }