大整数
This commit is contained in:
parent
a03e8acee0
commit
dfcbd84dc5
|
@ -0,0 +1,5 @@
|
||||||
|
package game
|
||||||
|
|
||||||
|
// Container 容器
|
||||||
|
type Container[T any] interface {
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package game
|
||||||
|
|
||||||
|
// Item 物品接口定义
|
||||||
|
type Item[ID comparable] interface {
|
||||||
|
// GetID 获取物品id
|
||||||
|
GetID() ID
|
||||||
|
// GetCount 获取物品数量
|
||||||
|
GetCount() int
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package huge
|
||||||
|
|
||||||
|
import "math/big"
|
||||||
|
|
||||||
|
type Int big.Int
|
||||||
|
|
||||||
|
func NewInt[T uint | uint8 | uint16 | uint32 | uint64 | int | int8 | int16 | int32 | int64](x T, exp ...T) *Int {
|
||||||
|
num := int64(x)
|
||||||
|
i := big.NewInt(num)
|
||||||
|
for _, t := range exp {
|
||||||
|
i = i.Exp(i, big.NewInt(int64(t)), nil)
|
||||||
|
}
|
||||||
|
return (*Int)(i)
|
||||||
|
}
|
Loading…
Reference in New Issue