I'm learning Java and I'm trying little programs. I have a problem with this one:
/*
Compute the number of cubic inches
in 1 cubic mile.
*/
class Inches {
public static void main(String args[]) {
int ci;
int im;
im = 5280 * 12;
ci = im * im * im;
System.out.println("There are " + ci + " cubic inches in cubic mile.");
}
}
The output is:
There are 1507852288 cubic inches in cubic mile.
I known the width in bits for a integer is 32, so the range is: -2,147,483,648 to 2,147,483,647
Why is the output 1507852288? It should be 2,147,483,647.
Thank you.