The read syntax for integers is a string of digits, optionally preceded by a minus or plus character, a code indicating the base in which the integer is encoded, and a code indicating whether the number is exact or inexact. The supported base codes are:
#b
#B
the integer is written in binary (base 2)
#o
#O
the integer is written in octal (base 8)
#d
#D
the integer is written in decimal (base 10)
#x
#X
the integer is written in hexadecimal (base 16)
If the base code is omitted, the integer is assumed to be decimal. The following examples show how these base codes are used.
-13 ⇒ -13 #d-13 ⇒ -13 #x-13 ⇒ -19 #b+1101 ⇒ 13 #o377 ⇒ 255
The codes for indicating exactness (which can, incidentally, be applied to all numerical values) are:
#e
#E
the number is exact
#i
#I
the number is inexact.
If the exactness indicator is omitted, the number is exact unless it contains a radix point. Since Guile can not represent exact complex numbers, an error is signaled when asking for them.
(exact? 1.2) ⇒ #f (exact? #e1.2) ⇒ #t (exact? #e+1i) ERROR: Wrong type argument
Guile also understands the syntax ‘+inf.0’ and ‘-inf.0’ for plus and minus infinity, respectively. The value must be written exactly as shown, that is, they always must have a sign and exactly one zero digit after the decimal point. It also understands ‘+nan.0’ and ‘-nan.0’ for the special ‘not-a-number’ value. The sign is ignored for ‘not-a-number’ and the value is always printed as ‘+nan.0’.