大整数

This commit is contained in:
kercylan98 2023-04-28 16:59:31 +08:00
parent a03e8acee0
commit dfcbd84dc5
3 changed files with 28 additions and 0 deletions

5
game/container.go Normal file
View File

@ -0,0 +1,5 @@
package game
// Container 容器
type Container[T any] interface {
}

9
game/item.go Normal file
View File

@ -0,0 +1,9 @@
package game
// Item 物品接口定义
type Item[ID comparable] interface {
// GetID 获取物品id
GetID() ID
// GetCount 获取物品数量
GetCount() int
}

14
utils/huge/int.go Normal file
View File

@ -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)
}