Using the Math.Pow function

user2999038

I have a constructor that returns the result of two ints with a 'to the power of' operator. I am trying to use the math.pow method to do this but im not to sure how it work.

Here is my constructor

public int Power (int firstNumber, int secondNumber)
{
    result = Math.Pow(firstNumber, secondNumber);
    return result;
}

and the code that calls it

case "^":
    result = application.Power(firstInt, secondInt);
    labelResult.Text = ("" + result);
    break;

How do i use the Math.Pow method in this situation?

Michael Roy

As far as the error you're getting:

Math.Pow takes 2 doubles as arguments and returns a double. Your method is declared as returning an int. This means that result is an int. You need to cast the result of Math.Pow to int:

result = (int)Math.Pow(firstNumber, secondNumber);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Using Math.pow() function

From Dev

pow() function working without any math libraries

From Dev

Using Math.Pow with Microsoft Solver Foundation

From Dev

Using Math.Pow with Microsoft Solver Foundation

From Dev

Manual Math.pow using BigDecimal in Java

From Dev

Monthly Loan Calculation using Math.Pow

From Dev

Exponents without using the pow() function

From Dev

Cannot use math.pow function in NodeMCU/ESP8266

From Dev

how to properly use math.pow java function?

From Dev

Is there has a function Math.Pow(A,n) for long type?

From Dev

Write Pow Function Without math.h in C

From Dev

Cannot use math.pow function in NodeMCU/ESP8266

From Dev

how to properly use math.pow java function?

From Dev

Is there has a function Math.Pow(A,n) for long type?

From Dev

Using recursion in math.pow to calculate power in java

From Dev

Finding squares of big numbers in python using math.pow

From Dev

Using overridden math function

From Dev

charAt() and Math.pow()

From Dev

Math.pow() on inputVal

From Dev

calculate mod using pow function python

From Dev

Understanding what is function overloading concept while using the pow function

From Dev

Can I replace the built-in pow function using this custom function?

From Dev

Understanding what is function overloading concept while using the pow function

From Dev

Comparing Math.Log and Math.Pow

From Dev

Casting Math.Pow to float

From Dev

Java Math.pow is not working

From Dev

JavaScript implementation of Math.pow

From Dev

Java Math.pow is not working

From Dev

Replace ** with Math.pow in SymPy