This module contains some handy functions to convert numbers
to strings and vice-versa, as well some
`<character>`

to `<string>`

conversions. [Note: It might be a good idea to
try making `string-to-integer`

and
`integer-to-string`

methods on
`as`

, which is the usual generic for type
coercions. Ask about this on the GD mailing list.]

`as` | [Function] |

Convert a character to a string.

**Synopsis**

as (class,character) => (string)

**Parameters**

classAn instance of `singleton(<string>)`

.characterAn instance of `<character>`

.

**Return Values**

stringAn instance of `<string>`

.

**Description**

`as(<string>, character)`

returns a fresh instance of`<string>`

of size 1, whose only element is the character.

`digit-to-integer` | [Function] |

Convert a character to the integer it denotes.

**Synopsis**

digit-to-integer (character) => (integer)

**Parameters**

characterAn instance of `<character>`

. An error is signalled character it is not alphanumeric.

**Return Values**

integerAn instance of `<integer>`

. Between 0 and 35, inclusive.

**Description**

`Digit-to-integer`

converts an alphanumeric character to an integer. '0' through '9' convert to 0 to 9, and 'a' through 'z' convert to 10 to 35. An error is signalled if the character is not in this range.

`integer-to-digit` | [Function] |

Convert an integer to the corresponding digit.

**Synopsis**

integer-to-digit (digit, #keybase,uppercase) => (digit)

**Parameters**

digitAn instance of `<integer>`

.`base:`

An instance of `<integer>`

. Between 2 and 35, inclusive, representing the radix of the digit to return. The default base is 10.`uppercase:`

An instance of `<boolean>`

. For`#t`

returns uppercase letters for digits greater than 10, and lowercase for`#f`

. The default is`#f`

.

**Return Values**

digitAn instance of `<character>`

. The returned digit is an alphanumeric character.

**Description**

`Integer-to-digit`

converts an integer to the corresponding digit in the specified base. If the integer is outside the range a single digit in the specified base can represent, an error is signalled. Digits for values of 10 or higher are represented with the letters 'a' through 'z', with 'a' for 10 and 'z' for 35.

`integer-to-string` | [Function] |

Converts an integer to a string value.

**Synopsis**

integer-to-string (num, #keybase,uppercase) => (number)

**Parameters**

numAn instance of `<integer>`

.`base:`

An instance of `<integer>`

.`Base:`

should be between 2 and 36, inclusive, and is the radix of the string representation. An error will be signalled for radixes not in this range. Defaults to`10`

.`uppercase:`

An instance of `<boolean>`

. If it is`#t`

, then uppercase letters will be used to represent digits higher than 9, and lowercase will be used if`#f`

.

**Return Values**

numberAn instance of `<string>`

.

**Description**

`Integer-to-string`

converts an integer to a string. String representations for radixes above 10 use the letters 'a' through 'z' for the digits from 10 to 35. So hexadecimal numbers would use [0-9] and [a-f], and base 20 would use [0-9] and [a-j], and base 36 would use all the alphanumeric characters.

`string-to-integer` | [Function] |

Read a sequence of characters as an integer.

**Synopsis**

string-to-integer (string, #keybase) => (integer)

**Parameters**

stringAn instance of `<sequence>`

. Any`<sequence>`

of`<character>`

objects are acceptable. This is typically but not necessarily a`<string>`

.`base:`

An instance of `<integer>`

. Between 2 and 36, inclusive, denoting the base to read integers in. An error is signalled if base is not in this range. Defaults to`10`

.

**Return Values**

integerAn instance of `<integer>`

.

**Description**

`String-to-integer`

converts a sequence of`<character>`

objects to an integer. The characters are the digits of the string representation, and must lie between '0' and 'z', with a maximum depending on the base. For example, octal (base 8) digits must be in [0-7], decimal digits must be in [0-9], and hexadecimal digits must be in [0-9] or [a-f]. An error is signalled if this constraint is violated. (Start negative integers with a '-', so "-36" would become -36.)