string_to_number


string_to_number(s, @optional radix = 10)
      

Return the number represented by the string s. Raise an error if s cannot be parsed as a number.

The number is interpreted in radix, which must be an exact integer from the set #(2, 8, 10, 16). Radix defaults to 10. Any radix specifier within the string, e.g., 0x, will override the radix argument.

Examples:


string_to_number("3.4e3") + 1
// 3401.

string_to_number("0x-2e2", 16)
// -738

string_to_number("0x-2e2", 10)
// -738
      

Also see:

number_to_string


Core Module Index | Contents