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:
parent
a66637bda4
commit
2e3d324cc6
1 changed files with 2 additions and 0 deletions
|
|
@ -8,12 +8,14 @@ type JsBigInt* = distinct JsBigIntImpl ## Arbitrary precision integer for
|
||||||
|
|
||||||
func big*(integer: SomeInteger): JsBigInt {.importjs: "BigInt(#)".} =
|
func big*(integer: SomeInteger): JsBigInt {.importjs: "BigInt(#)".} =
|
||||||
## Constructor for `JsBigInt`.
|
## Constructor for `JsBigInt`.
|
||||||
|
when nimvm: doAssert false, "JsBigInt can not be used at compile-time nor static context" else: discard
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
doAssert big(1234567890) == big"1234567890"
|
doAssert big(1234567890) == big"1234567890"
|
||||||
doAssert 0b1111100111.big == 0o1747.big and 0o1747.big == 999.big
|
doAssert 0b1111100111.big == 0o1747.big and 0o1747.big == 999.big
|
||||||
|
|
||||||
func big*(integer: cstring): JsBigInt {.importjs: "BigInt(#)".} =
|
func big*(integer: cstring): JsBigInt {.importjs: "BigInt(#)".} =
|
||||||
## Constructor for `JsBigInt`.
|
## Constructor for `JsBigInt`.
|
||||||
|
when nimvm: doAssert false, "JsBigInt can not be used at compile-time nor static context" else: discard
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
doAssert big"-1" == big"1" - big"2"
|
doAssert big"-1" == big"1" - big"2"
|
||||||
# supports decimal, binary, octal, hex:
|
# supports decimal, binary, octal, hex:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue