This has led me to look at Java numeric types a little more closely (and with a decade more cynicism than last time).
I'd forgotten entirely that there were
longnumeric types - for pretty much any use I've made of numbers in Java ever,
inthas been fine.
shortbehaves a little surprisingly:
a & bis a
a & bis an
a & bis an ...
int. wtf. why?
byte & byte->
This is specified in 5.6.2 Binary Numeric Promotion of the Java language specification.
Its pointed out that C also does implicit casting of smaller types to
int; but gcc is a little gentler with its warnings.
a+bgives a warning (not an error) similar to the Java code above, but
a&bdoes not (presumably because it knows that this can't make the number be any bigger than the types you started out with... something that gets lost in the Java type checking)