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 {
71
71
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/toString
72
72
*/
73
73
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
74
82
}
75
83
76
84
Original file line number Diff line number Diff line change @@ -24,12 +24,18 @@ class BigIntTest {
24
24
@ Test def apply (): Unit = {
25
25
val fromString = js.BigInt (" 9007199254740992" )
26
26
assertEquals(fromString.toString(), " 9007199254740992" )
27
+ assertEquals(fromString.toString(16 ), " 20000000000000" )
28
+ assertEquals(fromString.toString(3 ), " 1121202011211211122211100012101112" )
27
29
28
30
val fromInt = js.BigInt (2147483647 )
29
31
assertEquals(fromInt.toString(), " 2147483647" )
32
+ assertEquals(fromInt.toString(16 ), " 7fffffff" )
33
+ assertEquals(fromInt.toString(3 ), " 12112122212110202101" )
30
34
31
35
val fromDouble = js.BigInt (4294967295d )
32
36
assertEquals(fromDouble.toString(), " 4294967295" )
37
+ assertEquals(fromDouble.toString(16 ), " ffffffff" )
38
+ assertEquals(fromDouble.toString(3 ), " 102002022201221111210" )
33
39
}
34
40
35
41
@ Test def asIntN (): Unit = {
You can’t perform that action at this time.
0 commit comments