Skip to content

Commit 0a39620

Browse files
committed
bigint.export, bigint.import
1 parent f6c6e7d commit 0a39620

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/Runtime Environment/Bigint.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,24 @@ Non-deterministically check if a number is prime.
116116
local bigint = require "pluto:bigint"
117117
print(new bigint(91):isprobableprime(10)) --> false
118118
```
119+
120+
---
121+
### `bigint.export`
122+
Exports the bigint to a big-endian binary string.
123+
#### Parameters
124+
1. The bigint.
125+
2. The minimum number of bytes to return.
126+
```pluto
127+
local bigint = require "pluto:bigint"
128+
print(new bigint("1056"):export():tohex()) --> 0420
129+
print(new bigint("1056"):export(4):tohex()) --> 00000420
130+
```
131+
132+
---
133+
### `bigint.import`
134+
Creates a bigint from a big-endian binary string.
135+
```pluto
136+
local bigint = require "pluto:bigint"
137+
print(bigint.import("\x04\x20"):tostring()) --> 1056
138+
print(bigint.import("\x00\x00\x04\x20"):tostring()) --> 1056
139+
```

0 commit comments

Comments
 (0)