Problems with long type

It seems that constants are treated like signed integers in Java, while there is no mention of this in the language specification:

class test{

publicstaticvoid main(String[] args){

long a = 0x7FFFFFFF + 0x80000000;

System.out.println( a );

}

}

The above code compiles but gives wrong result (-1). Variable 'a' is a long, so the result should be 4294967295. Am I missing something?

[704 byte] By [TheBuggera] at [2007-11-26 20:01:28]
# 1
Well you didn't put L after the values, so maybe it made an int and then widened the scope retaining the sign.
TimRyanNZa at 2007-7-9 23:00:02 > top of Java-index,Java Essentials,Java Programming...
# 2
the spec clearly says that all integer constants are by default of the int type.a constant is considered of the long type if and only if it is suffixed by an upper or lower case L, for example 0x80000000L.
jsalonena at 2007-7-9 23:00:02 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks. It was an omission on my part.
TheBuggera at 2007-7-9 23:00:02 > top of Java-index,Java Essentials,Java Programming...