mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user