1 Star 0 Fork 0

技术狼/go-amount-decimal

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
amountdecimal_type_uint8.go 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
技术狼 提交于 2023-12-29 10:42 . no message
package amountdecimal
import "errors"
// @title: initialization uint8 type
// @auth: jishulang.com
// @date: 2022/7/30 20:59
func NewUint8(amount uint8) *AmountDecimal {
return NewUint64(uint64(amount))
}
// @title: addition uint8 type
// @auth: jishulang.com
// @date: 2022/7/30 20:59
func (c *AmountDecimal) AddUint8(amounts ...uint8) *AmountDecimal {
return c.amountsUint8(add, amounts...)
}
// @title: subtraction uint8 type
// @auth: jishulang.com
// @date: 2022/7/30 20:59
func (c *AmountDecimal) SubUint8(amounts ...uint8) *AmountDecimal {
return c.amountsUint8(sub, amounts...)
}
// @title: multiplication uint8 type
// @auth: jishulang.com
// @date: 2022/7/30 20:59
func (c *AmountDecimal) MulUint8(amounts ...uint8) *AmountDecimal {
return c.amountsUint8(mul, amounts...)
}
// @title: division uint8 type
// @auth: jishulang.com
// @date: 2022/7/30 20:59
func (c *AmountDecimal) DivUint8(amounts ...uint8) *AmountDecimal {
return c.amountsUint8(div, amounts...)
}
func (c *AmountDecimal) amountsUint8(f uint8, amounts ...uint8) *AmountDecimal {
if c.err != nil {
return c
}
if len(amounts) == 0 {
c.err = errors.New(errCodeMap[amounts_empty])
return c
}
var amounts2 []uint64
for _, amount := range amounts {
amounts2 = append(amounts2, uint64(amount))
}
return c.amountsUint64(f, amounts2...)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/jishulangcom/go-amount-decimal.git
git@gitee.com:jishulangcom/go-amount-decimal.git
jishulangcom
go-amount-decimal
go-amount-decimal
v0.0.1

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385