# Problem regarding multiplication

• 03-10-2010, 08:17 AM
javanewbie1234
Problem regarding multiplication
Code:

``` public class Savings {         public static void main(String [] args)         {        int p=1000,r=4;int a;                 int x=(int)Math.pow((1+r),10); //Output -- 9765625                 a=p*(int)Math.pow((1+r),10); // Output -- 1175690408                 System.out.println(x+"\n"+a);         } }```
its just a simple code. but am having trouble with it

9765625 *1000 == 9765625000 isnt it? then why is it showing such an output?
• 03-10-2010, 10:27 AM
JosAH
Quote:

Originally Posted by javanewbie1234
Code:

``` public class Savings {         public static void main(String [] args)         {        int p=1000,r=4;int a;                 int x=(int)Math.pow((1+r),10); //Output -- 9765625                 a=p*(int)Math.pow((1+r),10); // Output -- 1175690408                 System.out.println(x+"\n"+a);         } }```
its just a simple code. but am having trouble with it

9765625 *1000 == 9765625000 isnt it? then why is it showing such an output?

... because an int has four bytes and 9765625000 doesn't fit in four bytes.

kind regards,

Jos