fix(mathutil): format TruncRound integer inputs as floats (#365)

This commit is contained in:
Yusuf Efe authored and GitHub committed 2026-10-23 20:54:59 +08:00
1 parent f220ea4c3f
commit a296281408
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -93,7 +93,7 @@ func RoundToFloat[T constraints.Float | constraints.Integer](x T, n int) float64
// TruncRound round off n decimal places.
// Play: https://go.dev/play/p/aumarSHIGzP
func TruncRound[T constraints.Float | constraints.Integer](x T, n int) T {
floatStr := fmt.Sprintf("%."+strconv.Itoa(n+1)+"f", x)
floatStr := fmt.Sprintf("%."+strconv.Itoa(n+1)+"f", float64(x))
temp := strings.Split(floatStr, ".")
var newFloat string
if len(temp) < 2 || n >= len(temp[1]) {