Files
zogo/numx/README.md
T
4566704 263cf78317 feat(numx): 自 go-hua/common 迁入数值工具并独立成包
- 流量格式化、低位取整、多整数取最值(Max/Min 自 version.go 归位)
- 附单元测试、examples/numx 例程与包 README
2026-09-20 12:20:51 +08:00

24 lines
781 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# numx
数值处理与可读格式化工具:流量字节数格式化、数字低位取整、多整数取最值。
> 迁移自 go-hua/common(原 number.go / format.go / version.go 中的 Max/Min)。
## 用法
```go
import "git.zeroonesoft.cn/golib/zogo/numx"
numx.FormatFlow(1536) // "1.5 KB"(B/KB/MB/GB/TB)
numx.IgnoreDigits(12345, 3) // 12000(低位取整补零)
numx.Max(3, 7, 5) // 7
numx.Min(3, 1, 2) // 1
```
完整可运行例程:[examples/numx/main.go](../examples/numx/main.go)
## 注意
- Go 1.21+ 内置 `max`/`min` 只支持两参数,多参数场景仍可用本包 `Max/Min`。
- `Min` 无法区分"全零参数"与"未传参数",全负数取最小值请用 `Max` 的负值或自行比较。