Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. JavaScript error reference
  5. RangeError: radix must be an integer

RangeError: radix must be an integer

The JavaScript exception "radix must be an integer at least 2 and no greater than 36"occurs when the optionalradix parameter of theNumber.prototype.toString() ortheBigInt.prototype.toString() method was specified and is not between 2and 36.

Message

RangeError: toString() radix argument must be between 2 and 36 (V8-based & Safari)RangeError: radix must be an integer at least 2 and no greater than 36 (Firefox)

Error type

RangeError

What went wrong?

The optionalradix parameter of theNumber.prototype.toString() ortheBigInt.prototype.toString() method was specified. Its value must be aninteger (a number) between 2 and 36, specifying the base of the number system to be usedfor representing numeric values. For example, the decimal (base 10) number 169 isrepresented in hexadecimal (base 16) as A9.

Why is this parameter's value limited to 36? A radix that is larger than 10 usesalphabetical characters as digits; therefore, the radix can't be larger than 36, sincethe Latin alphabet (used by English and many other languages) only has 26 characters.

The most common radixes:

Examples

Invalid cases

js
(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

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

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp