@@ -10,60 +10,71 @@ local bigint = require "pluto:bigint"
10
10
print(new bigint("123")) --> 123
11
11
```
12
12
13
+ ---
13
14
### ` bigint.tostring ` , ` __tostring `
14
15
As seen above, the ` __tostring ` metamethod provides a string representation of the Bigint in decimal.
15
16
17
+ ---
16
18
### ` bigint.hex `
17
19
Provides a hexadecimal representation of the Bigint.
18
20
``` pluto
19
21
local bigint = require "pluto:bigint"
20
22
print(new bigint("420"):hex()) --> 1A4
21
23
```
22
24
25
+ ---
23
26
### ` bigint.binary `
24
27
Provides a binary representation of the Bigint.
25
28
``` pluto
26
29
local bigint = require "pluto:bigint"
27
30
print(new bigint("420"):binary()) --> 110100100
28
31
```
29
32
33
+ ---
30
34
### ` bigint.add ` , ` __add `
31
35
Adds two bigints together. Returns a new bigint.
32
36
37
+ ---
33
38
### ` bigint.sub ` , ` __sub `
34
39
Performs subtraction on two bigints. Returns a new bigint.
35
40
41
+ ---
36
42
### ` bigint.mul ` , ` __mul `
37
43
Performs multiplication on two bigints. Returns a new bigint.
38
44
45
+ ---
39
46
### ` bigint.div `
40
47
Performs division on two bigints. Returns two new bigints: quotient and remainder.
41
48
``` pluto
42
49
local bigint = require "pluto:bigint"
43
50
print(new bigint(10):div(new bigint(3))) --> 3 1
44
51
```
45
52
53
+ ---
46
54
### ` __div `
47
55
Performs division on two bigints. Returns a new bigint with the quotient.
48
56
``` pluto
49
57
local bigint = require "pluto:bigint"
50
58
print(new bigint(10) / new bigint(3)) --> 3
51
59
```
52
60
61
+ ---
53
62
### ` bigint.mod ` , ` __mod `
54
63
Performs divison on two bigints. Returns a new bigint with the remainder.
55
64
``` pluto
56
65
local bigint = require "pluto:bigint"
57
66
print(new bigint(10) % new bigint(3)) --> 1
58
67
```
59
68
69
+ ---
60
70
### ` bigint.pow ` , ` __pow `
61
71
Performs expontentiation on two bigints. Returns a new bigint.
62
72
``` pluto
63
73
local bigint = require "pluto:bigint"
64
74
print(new bigint(2) ^ new bigint(10)) --> 1024
65
75
```
66
76
77
+ ---
67
78
### ` bigint.bitlength `
68
79
Returns the position of the most significant set bit as a plain integer.
69
80
``` pluto
0 commit comments