I learn Java and I try to make small programs. I have a problem with this:
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.");
}
}
Conclusion:
There are 1507852288 cubic inches in cubic mile.
I knew the width in bits for an integer 32, so the range is -2,147,483,648 to 2,147,483,647
Why is the conclusion 1507852288? It should be 2,147,483,647.
Thank.
source
share