Literals
Bool
, Double
, Int32
,
Int64
, and String
literals can be present in
an expression.
- A
Bool
literal can be eithertrue
orfalse
. - A
Double
literal is a decimal number that either contains the decimal separator (e.g.,3.5
,.5
,3.
) or is given in the scientific notation (e.g.,1e-4
,1.5e3
). A Double literal must be between(2 - 2 ^ -52) * 2 ^ 1023
(~ 1.79 * 10 ^ 308
) and-(2 - 2 ^ -52) * 2 ^ 1023
(~ -1.79 * 10 ^ 308
). Moreover, the magnitude of a literal cannot be less than2 ^ -1074
(~ 4.94 * 10 ^ -324
). Furthermore,- a
NaN
(not a number) value can be specified through theDouble("nan")
expression, - an
Inf
(positive infinity) value can be specified through theDouble("inf")
expression, - and a
-Inf
(negative infinity) value can be specified through theDouble("-Inf")
expression.
- a
- Integer literals without a suffix are of the
Int32
type (e.g.,14
). AnInt32
literal must be between2 ^ 31 - 1
(= 2147483647
) and-2 ^ 31
(= -2147483648
). - The
L
suffix is used to createInt64
literals (e.g.,14L
). AnInt64
literal must be between2 ^ 63 - 1
(= 9223372036854775807L
) and-2 ^ 63
(= -9223372036854775808L
). - A
String
literal appears within double quotes, as in"I'm a string literal"
. The escape character\
can be used to represent new line (\n
), tab (\t
), double quote (\"
) characters, as well as the escape character itself (\\
).