I tried the following:
public static final long DEVICE_ID_UNKNOWN = 0xFFFFFFFFFFFFFFFF;
but it causes
The literal 0xFFFFFFFFFFFFFFFF of type int is out of range
I tried the following:
public static final long DEVICE_ID_UNKNOWN = 0xFFFFFFFFFFFFFFFF;
but it causes
The literal 0xFFFFFFFFFFFFFFFF of type int is out of range
Use 0xFFFFFFFFFFFFFFFFl
and be fine.
Another way would be to use simply -1
because this value also has all bits set. See http://en.wikipedia.org/wiki/Two%27s_complement for details.
You need to specify the type of the number if it can not be represented as an int. A long is a L or l (lowercase). I prefer uppercase as lowercase is easy to mistake for 1 (one).
public static final long DEVICE_ID_UNKNOWN = 0xFFFFFFFFFFFFFFFFL;
Or, you can just set the value to -1, but that might not be as clear in communicating the meaning "all bits 1".
You may use either of the following:
public static final long DEVICE_ID_UNKNOWN = 0xFFFFFFFFFFFFFFFFL;
or
public static final long DEVICE_ID_UNKNOWN = ~0L;
or
public static final long DEVICE_ID_UNKNOWN = -1L;
Yet another way to get all 1s
public static final long DEVICE_ID_UNKNOWN = ~0L;
Use public static final long DEVICE_ID_UNKNOWN = 0xFFFFFFFFFFFFFFFFL;
instead to signify that it's a long value, not an int value.
public static final long DEVICE_ID_UNKNOWN = 0xFFFF_FFFF_FFFF_FFFFL;
Usefull reference http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html