mirror of
https://github.com/duke-git/lancet.git
synced 2025-10-05 07:26:51 +08:00
doc: update doc for mathutil package
This commit is contained in:
@@ -101,6 +101,7 @@ func TruncRound[T constraints.Float | constraints.Integer](x T, n int) T {
|
||||
}
|
||||
|
||||
// FloorToFloat round down to n decimal places.
|
||||
// Play: todo
|
||||
func FloorToFloat[T constraints.Float | constraints.Integer](x T, n int) float64 {
|
||||
tmp := math.Pow(10.0, float64(n))
|
||||
x *= T(tmp)
|
||||
@@ -109,6 +110,7 @@ func FloorToFloat[T constraints.Float | constraints.Integer](x T, n int) float64
|
||||
}
|
||||
|
||||
// FloorToString round down to n decimal places.
|
||||
// Play: todo
|
||||
func FloorToString[T constraints.Float | constraints.Integer](x T, n int) string {
|
||||
tmp := math.Pow(10.0, float64(n))
|
||||
x *= T(tmp)
|
||||
@@ -118,6 +120,7 @@ func FloorToString[T constraints.Float | constraints.Integer](x T, n int) string
|
||||
}
|
||||
|
||||
// CeilToFloat round up to n decimal places.
|
||||
// Play: todo
|
||||
func CeilToFloat[T constraints.Float | constraints.Integer](x T, n int) float64 {
|
||||
tmp := math.Pow(10.0, float64(n))
|
||||
x *= T(tmp)
|
||||
@@ -126,6 +129,7 @@ func CeilToFloat[T constraints.Float | constraints.Integer](x T, n int) float64
|
||||
}
|
||||
|
||||
// CeilToString round up to n decimal places.
|
||||
// Play: todo
|
||||
func CeilToString[T constraints.Float | constraints.Integer](x T, n int) string {
|
||||
tmp := math.Pow(10.0, float64(n))
|
||||
x *= T(tmp)
|
||||
@@ -387,6 +391,7 @@ func Abs[T constraints.Integer | constraints.Float](x T) T {
|
||||
}
|
||||
|
||||
// Div returns the result of x divided by y.
|
||||
// Play: todo
|
||||
func Div[T constraints.Float | constraints.Integer](x T, y T) float64 {
|
||||
return float64(x) / float64(y)
|
||||
}
|
||||
|
Reference in New Issue
Block a user