[["X(B(STUUUUTTUUUUY677776777767777767776F66666666XC(CC(C(.CCSTTUUUUTTUUUU","wrsssrk.","Math.Pow"," computes exponential values. It takes the powers of numbers such as by squaring values. It is a simple and convenient way to compute exponents in the C# language. There are issues related to its usage.","Example."," This program computes the powers of various numbers using the Math.Pow method. The parameters must be doubles or types that are convertible to double types. The compiler automatically converts the parameters for you if it can. ","Double ","double","The first parameter"," indicates the number you are trying to base the result on. The second parameter is the exponent itself. If you are trying to square two, you will use 2, 2 as the parameters. ","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","C# program that uses Math.Pow method","\n\nusing System;\n\nclass Program\n{\n static void Main()\n {","\n //\n // Compute the squares of the first parameters to Math.Pow.\n //\n ","double value1 = ","Math.Pow","(2, 2);\n double value2 = ","Math.Pow","(3, 2);\n double value3 = ","Math.Pow","(4, 2);\n double value4 = ","Math.Pow","(5, 2);","\n //\n // Compute the cubes of these values.\n //\n ","double value5 = ","Math.Pow","(2, 3);\n double value6 = ","Math.Pow","(3, 3);\n double value7 = ","Math.Pow","(4, 3);\n double value8 = ","Math.Pow","(5, 3);","\n //\n // Check some edge cases with the smallest, biggest, and special values.\n //\n ","double value9 = ","Math.Pow","(double.MinValue, double.MaxValue);\n double value10 = ","Math.Pow","(double.MinValue, 0);\n double value11 = ","Math.Pow","(double.NaN, 2);\n double value12 = ","Math.Pow","(double.PositiveInfinity, 2);\n double value13 = ","Math.Pow","(double.NegativeInfinity, 2);","\n //\n // Compute fractional powers.\n //\n ","double value14 = ","Math.Pow","(2, 2.1);\n double value15 = ","Math.Pow","(Math.E, 2);\n double value16 = ","Math.Pow","(Math.PI, 1);","\n //\n // Write results to the screen.\n //\n ","Console.WriteLine(value1);\n Console.WriteLine(value2);\n Console.WriteLine(value3);\n Console.WriteLine(value4);\n Console.WriteLine(value5);\n Console.WriteLine(value6);\n Console.WriteLine(value7);\n Console.WriteLine(value8);\n Console.WriteLine(value9);\n Console.WriteLine(value10);\n Console.WriteLine(value11);\n Console.WriteLine(value12);\n Console.WriteLine(value13);\n Console.WriteLine(value14);\n Console.WriteLine(value15);\n Console.WriteLine(value16);\n }\n}\n\n","Output","\n\n4"," Two squared.\n","9"," Three squared.\n","16"," Four squared.\n","25"," Five squared.\n","8"," Two cubed (2 * 2 * 2).\n","27"," Three cubed (3 * 3 * 3).\n","64"," Four cubed (4 * 4 * 4).\n","125"," Five cubed (5 * 5 * 5).\n","Infinity\n1\nNaN\nInfinity\nInfinity\n4.28709385014517\n7.38905609893065\n3.14159265358979","The program first demonstrates"," the usage of the Math.Pow method in the System namespace by calling it with common small integer parameters. You will know the values of two squared, three squared, four squared, and five squared. ","Next: ","The program also cubes those small integers. The Math.Pow method returns a double type number.","Math.Pow"," will handle any numbers without throwing an exception. The program will only compile if the parameters can be implicitly cast to the double type or are already of double type. ","Note: ","You can see the program shows what powers are displayed as Infinity and NaN values.","Note 2: ","The double type reserves certain bit arrangements as representations of these special values.","Discussion."," The Math.Pow method is not an extremely inefficient method. But if you can somehow cache the power number in a local variable, the execution time of your method will likely be reduced. ","Note: ","The Math.Pow method is implemented in code external to the managed code shipped as part of the .NET Framework.","The book"," Code Complete by Steve McConnell shows specific optimization techniques. You can use arrays as lookup tables to cache the results of common numeric computations such as logarithms (or exponents) in your programs.","Summary."," We saw the Math.Pow method, which provides a clear way to compute exponential values. The variable returned is a double type and this must be cast down to an integer if you need an integer. ","Here: ","We looked at some common parameter to the Math.Pow method. We noted its exact execution and results.","Then: ","We noted some related issues to computing powers in computer programming languages.","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","3679700504","data-ad-format","link","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto"],"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABBCAMAAACjORu8A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vABmT3G65DUKhQpqB9FHE/TooDw5BZpi9H5N/5Xutf9vvh7YhDWP/AAAAAElFTkSuQmCC)","url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAACCAgMAAADasxWRAAAADFBMVEXZ7/////+VlZX29vYl5th1AAAASElEQVR4AWPACZj/f0DmjkqOSjKtQgcLyJccZiEE9SOmP8mXHEaBMBoIo4EwGggryJccvvVKKAogTnJUclRyVHLklgmjkqOSAALWyrsxEHLDAAAAAElFTkSuQmCC)","url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAACCAgMAAADasxWRAAAADFBMVEX/6Nn///+VlZX29va5ksB5AAAASElEQVR4AWPACZj/f0DmjkqOSjKtQgcLyJccZiEE9SOmP8mXHEaBMBoIo4EwGggryJccvvVKKAogTnJUclRyVHLklgmjkqOSAALWyrsxEHLDAAAAAElFTkSuQmCC)"]

["url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABDCAMAAADu8bq3AAAAMFBMVEX/////87L/99H/63he//Os//jR//v/507/7pH//fX/++aO//b/5C/p//0A//D0//4M59PNAAAC9klEQVR4XtXa627qMBCFUc+M77nw/m97dFAreWscJg2BOPsfpTJdEp8SQd0QW5sFd8FGgqzdxS4grt2NBrFPC/eD+C7E3w+yGuiRIXYk8Y6QYCQyMMSOxN8RshrmcSF2JPGeEH1euCdkUpDpcxDf7GzIeuA3L926N5J4T4iOJNwJEjxEspWID6ND4P2zLY5ueMhjKxIgPvZBmIlE0vx/STJxOQNQmJ5niuCBCHFeRaIT8c6C1OeL6WX+63VkbkbOOc7qwD5k6keCT7yGUAYDTuobkEL6ZCldSBuJ37pjjK8h88slPgyR1D2wdiAIWxrH0nINiLF6FIJDiYZMcGQvkelNSCrnQmYpPUjoRYI+A5IsST4ZMpOGYCQbiRgQma3VkyGpKAhWvfQTeRtCJ0NmUhAdiU7kfYicDUka0o8EdfshSZ5TF8ezIXPtQBYdCb7fLAgRM3MBXM0YyWGIPE9X11x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