From ccb900b041418e2b62bea19efd97de7861692156 Mon Sep 17 00:00:00 2001 From: Dilrong Date: Fri, 16 Jul 2021 12:37:49 +0900 Subject: bad_radix 동기화 및 번역 (#1382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 이학성 --- .../global_objects/bigint/tostring/index.html | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 files/ko/web/javascript/reference/global_objects/bigint/tostring/index.html (limited to 'files/ko/web/javascript/reference/global_objects') diff --git a/files/ko/web/javascript/reference/global_objects/bigint/tostring/index.html b/files/ko/web/javascript/reference/global_objects/bigint/tostring/index.html new file mode 100644 index 0000000000..3b04cd9f84 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/bigint/tostring/index.html @@ -0,0 +1,102 @@ +--- +title: BigInt.prototype.toString() +slug: Web/JavaScript/Reference/Global_Objects/BigInt/toString +tags: +- BigInt +- JavaScript +- Method +- Prototype +- toString() +browser-compat: javascript.builtins.BigInt.toString +--- +
{{JSRef}}
+ +

The toString() method returns a string representing the + specified {{jsxref("BigInt")}} object. The trailing "n" is not part of the string.

+ +
{{EmbedInteractiveExample("pages/js/bigint-tostring.html")}}
+ +

Syntax

+ +
+toString()
+toString(radix)
+
+ +

Parameters

+ +
+
radix{{optional_inline}}
+
Optional. An integer in the range 2 through 36 specifying the base to use for + representing numeric values.
+
+ +

Return value

+ +

A string representing the specified {{jsxref("BigInt")}} object.

+ +

Exceptions

+ +
+
{{jsxref("RangeError")}}
+
If toString() is given a radix less than 2 or greater than 36, a + {{jsxref("RangeError")}} is thrown.
+
+ +

Description

+ +

The {{jsxref("BigInt")}} object overrides the toString() method of the + {{jsxref("Object")}} object; it does not inherit + {{jsxref("Object.prototype.toString()")}}. For {{jsxref( "BigInt")}} objects, the + toString() method returns a string representation of the object in the + specified radix.

+ +

The toString() method parses its first argument, and attempts to return a + string representation in the specified radix (base). For radixes above 10, the letters + of the alphabet indicate numerals greater than 9. For example, for hexadecimal numbers + (base 16) a through f are used.

+ +

If the radix is not specified, the preferred radix is assumed to be 10. +

+ +

If the bigIntObj is negative, the sign is preserved. This is the case even + if the radix is 2; the string returned is the positive binary representation of the + bigIntObj preceded by a - sign, not the two's + complement of the bigIntObj.

+ +

Examples

+ +

Using toString

+ +
17n.toString();      // '17'
+66n.toString(2);     // '1000010'
+254n.toString(16);   // 'fe'
+-10n.toString(2);    // -1010'
+-0xffn.toString(2);  // '-11111111'
+
+ +

Negative-zero BigInt

+ +

There is no negative-zero BigInt as there are no negative zeros in + integers. -0.0 is an IEEE floating-point concept that only appears in the + JavaScript {{jsxref("Number")}} type.

+ +
(-0n).toString();      // '0'
+BigInt(-0).toString(); // '0'
+ +

Specifications

+ +{{Specifications}} + +

Browser compatibility

+ + +

{{Compat}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf