File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
library/src/main/scala/scala/scalajs/js
test-suite/js/src/test/scala/org/scalajs/testsuite/library Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,14 @@ final class BigInt private[this] () extends js.Object {
7171 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString
7272 */
7373 override def toString (): String = js.native
74+
75+ /** Returns a string representation of this BigInt.
76+ *
77+ * The trailing "n" is not part of the string.
78+ *
79+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString
80+ */
81+ def toString (radix : Int ): String = js.native
7482}
7583
7684
Original file line number Diff line number Diff line change @@ -24,12 +24,18 @@ class BigIntTest {
2424 @ Test def apply (): Unit = {
2525 val fromString = js.BigInt (" 9007199254740992" )
2626 assertEquals(fromString.toString(), " 9007199254740992" )
27+ assertEquals(fromString.toString(16 ), " 20000000000000" )
28+ assertEquals(fromString.toString(3 ), " 1121202011211211122211100012101112" )
2729
2830 val fromInt = js.BigInt (2147483647 )
2931 assertEquals(fromInt.toString(), " 2147483647" )
32+ assertEquals(fromInt.toString(16 ), " 7fffffff" )
33+ assertEquals(fromInt.toString(3 ), " 12112122212110202101" )
3034
3135 val fromDouble = js.BigInt (4294967295d )
3236 assertEquals(fromDouble.toString(), " 4294967295" )
37+ assertEquals(fromDouble.toString(16 ), " ffffffff" )
38+ assertEquals(fromDouble.toString(3 ), " 102002022201221111210" )
3339 }
3440
3541 @ Test def asIntN (): Unit = {
You can’t perform that action at this time.
0 commit comments