1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

feat: add ToBigInt

This commit is contained in:
dudaodong
2024-12-02 11:25:16 +08:00
parent 8f3ea60636
commit 7fb49515ce
7 changed files with 217 additions and 61 deletions

View File

@@ -47,6 +47,7 @@ import (
- [ToUrlBase64](#ToUrlBase64)
- [ToRawStdBase64](#ToRawStdBase64)
- [ToRawUrlBase64](#ToRawUrlBase64)
- [ToBigInt](#ToBigInt)
<div STYLE="page-break-after: always;"></div>
@@ -1116,4 +1117,34 @@ func main() {
// map[a:1 b:2] false
// &{test 1 0.1 true <nil> } false
}
```
### <span id="ToBigInt">ToBigInt</span>
<p>Converts an integer of any supported type (int, int64, uint64, etc.) to *big.Int</p>
<b>Signature:<span style="float:right;display:inline-block;">[Run](todo)</span></b>
```go
func ToBigInt[T constraints.Integer](v T) (*big.Int, error)
```
<b>Example:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/convertor"
)
func main() {
n := 9876543210
bigInt, _ := convertor.ToBigInt(n)
fmt.Println(bigInt)
// Output:
// 9876543210
}
```