Improve Bigint (#17252)

* https://github.com/timotheecour/Nim/issues/566#issue-799927295

* Update lib/std/jsbigints.nim

Co-authored-by: flywind <xzsflywind@gmail.com>

* Update lib/std/jsbigints.nim

Co-authored-by: flywind <xzsflywind@gmail.com>

Co-authored-by: flywind <xzsflywind@gmail.com>
This commit is contained in:
Juan Carlos
2021-03-04 10:02:36 -03:00
committed by GitHub
parent a66637bda4
commit 2e3d324cc6

View File

@@ -8,12 +8,14 @@ type JsBigInt* = distinct JsBigIntImpl ## Arbitrary precision integer for
func big*(integer: SomeInteger): JsBigInt {.importjs: "BigInt(#)".} =
## Constructor for `JsBigInt`.
when nimvm: doAssert false, "JsBigInt can not be used at compile-time nor static context" else: discard
runnableExamples:
doAssert big(1234567890) == big"1234567890"
doAssert 0b1111100111.big == 0o1747.big and 0o1747.big == 999.big
func big*(integer: cstring): JsBigInt {.importjs: "BigInt(#)".} =
## Constructor for `JsBigInt`.
when nimvm: doAssert false, "JsBigInt can not be used at compile-time nor static context" else: discard
runnableExamples:
doAssert big"-1" == big"1" - big"2"
# supports decimal, binary, octal, hex: