string->number

Synopsis

(string->number string radix)

(string->number string)

Parameters

  • string
  • radix (optional)

Description

Returns a number of the maximally precise representation expressed by the given string. Radix must be an exact integer, either 2, 8, 10, or 16. If supplied, radix is a default radix that may be overridden by an explicit radix prefix in string (e.g. “#o177”). If radix is not supplied, then the default radix is 10. If string is not a syntactically valid notation for a number, then string->number returns #f.

Side Effects

Return Value

A number is returned.

Example

(string->number "100")      =>  100
(string->number "100" 16)   =>  256
(string->number "1e2")      =>  100.0
(string->number "15##")     =>  1500.0