# Board index » jbuilder » arithmatic operators

## arithmatic operators

2004-01-07 12:48:16 PM
jbuilder15
Greetings,
I know this may sound ignorant .... <G>
But how does one figure out a number = the power of another ?
ie: 10 to the power of 3 = 1000
How do I write that in my Java code if var1 = 10 and var2 = 3 and I want
answer1 ?
answer1 = var1 to the power of var2 ?
Thank you in advance !!!
Bruce

## Re:arithmatic operators

Bruce VanOrder wrote:
##### Quote
Greetings,

I know this may sound ignorant .... <G>

But how does one figure out a number = the power of another ?

ie: 10 to the power of 3 = 1000

How do I write that in my Java code if var1 = 10 and var2 = 3 and I want
answer1 ?

answer1 = var1 to the power of var2 ?

Thank you in advance !!!

Bruce
Nothing is a stupid question, unless you know the answer <G>.
Try something like this:
public static void main(String[] args) {
MainClass mainClass1 = new MainClass();
int a,b,c;
a=5;
b=2;
c=3;
double r=Math.pow((double)a,(double)b);
System.out.println(""+r);
}

## Re:arithmatic operators

Thank you for the answer... I knew there must have been either some
arithmatic operator I was missing or some function that would do it... I
know how to do it in C & Pascal.... :-) but I am trying to learn Java to
a better understanding ...
Have a great day...
pNichols wrote:
##### Quote
Bruce VanOrder wrote:

>Greetings,
>
>I know this may sound ignorant .... <G>
>
>But how does one figure out a number = the power of another ?
>
>ie: 10 to the power of 3 = 1000
>
>How do I write that in my Java code if var1 = 10 and var2 = 3 and I want
>answer1 ?
>
>answer1 = var1 to the power of var2 ?
>
>Thank you in advance !!!
>
>Bruce
>

Nothing is a stupid question, unless you know the answer <G>.

Try something like this:

public static void main(String[] args) {
MainClass mainClass1 = new MainClass();
int a,b,c;
a=5;
b=2;
c=3;
double r=Math.pow((double)a,(double)b);
System.out.println(""+r);
}

{smallsort}

## Re:arithmatic operators

Bruce VanOrder wrote:
##### Quote
Thank you for the answer... I knew there must have been either some
arithmatic operator I was missing or some function that would do it... I
know how to do it in C & Pascal.... :-) but I am trying to learn Java to
a better understanding ...

Can you get to the site now Bruse?