Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

RangeError: radix must be an integer

Os nossos voluntários ainda não traduziram este artigo para Português (Europeu) . Junte-se a nós e ajude-nos a fazer o trabalho!

Message

RangeError: radix must be an integer at least 2 and no greater than 36 (Firefox)
RangeError: toString() radix argument must be between 2 and 36 (Chrome)

Error type

RangeError

What went wrong?

The optional radix parameter with the Number.prototype.toString() method has been used. This parameter must be an integer (a number) between 2 and 36 specifying the base of the number system to be used for representing numeric values.

Why is it limited to 36? A radix that is larger than 10 uses alphabetical characters as digits. Therefore, the radix can not be larger than 36 as the Latin alphabet has 26 characters only.

You probably want to use one of the common radices:

Examples

Invalid cases

(42).toString(0);
(42).toString(1);
(42).toString(37);
(42).toString(150);
// You cannot use a string like this for formatting:
(12071989).toString("MM-dd-yyyy");

Valid cases

(42).toString(2);     // "101010" (binary)
(13).toString(8);     // "15"     (octal)
(0x42).toString(10);  // "66"     (decimal)
(100000).toString(16) // "186a0"  (hexadecimal)

See also

Etiquetas do documento e colaboradores

 Colaboradores para esta página: fscholz
 Última atualização por: fscholz,