#lang scribble/manual
@(require scribble/racket
scribble/eval
scribble/bnf)
@title{Literals}
@section{Numeric literals}
There are four types of numeric literals: integers, floating point, imaginary,
and inexact.
Integer literals come in four varieties: decimal integers, binary integers,
octal integers, and hexadecimal integers. Binary integers start with the prefix
@litchar{0b} or @litchar{0B}, octal integers start with the prefix
@litchar{0o} or @litchar{0O}, and hexadecimal integers start with the prefix
@litchar{0x} or @litchar{0X}.
Some examples of integer literals:
@codeblock|{
7
66
123456789123456789123456789
0o77
0xcafebabe
}|
Floating point numbers are lexed just as they are in Racket.
@codeblock|{
3.14
2.718
10.
.001
1e3
1e+3
1E-3
}|
Imaginary numbers are decimal integers or floating point numbers
suffixed with the letter @litchar{i}. (Note that a number of the
form a+bi is parsed as the addition of a real number and an
imaginary number with a real part of 0.)
@codeblock|{
1i
66i
10.i
3.14i
}|
Finally, a literal can be prefixed with @litchar{0nx}, to indicate
that it is inexact. (Here, a complex number such as 0nx2+3i parses
as the inexact number 2+3i, NOT the inexact number 2 + 3i).
@codeblock|{
0nx1.0
0nx2+3i
0nx4i
}|
@section{String literals}
String literals are read in exactly the same manner as they are in
Racket. See
@(hyperlink "http://docs.racket-lang.org/reference/reader.html?#(part._parse-string)"
"the Racket reference") for more information.