asNumber
This function returns a representation of the literal value as a number. This will return an integer, except for the case when the literal has the value 2147483648. This special literal is only allowed in the expression -2147483648 which represents Integer.MIN_VALUE). However 2147483648 (2^31) is out of range of int, which is -(2^31) to (2^31)-1 and thus a long must be returned.
Note, that this function will NOT return a negative number if the literal was specified in decimal, since according to the language specification (chapter 3.10.1) an expression such as -1 is represented by a unary expression with a minus operator and the literal 1. It is however possible to represent negative numbers in a literal directly, i.e. by using the binary or hexadecimal representation. For example 0xffff_ffff represents the value -1.
Return
the literal value as a number while respecting different number representations