1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

doc: update doc for mathutil package

This commit is contained in:
dudaodong
2024-03-04 19:52:49 +08:00
parent f7b54986aa
commit a54d4c79a0
4 changed files with 67 additions and 4 deletions

View File

@@ -500,7 +500,7 @@ func main() {
### <span id="CeilToFloat">CeilToFloat</span>
<p>向上舍入(进一法),保留 n 位小数</p>
<p>向上舍入(进一法),保留n位小数</p>
<b>函数签名:</b>
@@ -536,7 +536,7 @@ func main() {
### <span id="CeilToString">CeilToString</span>
<p>向上舍入(进一法),保留 n 位小数,返回字符串</p>
<p>向上舍入(进一法),保留n位小数,返回字符串</p>
<b>函数签名:</b>
@@ -572,7 +572,7 @@ func main() {
### <span id="FloorToFloat">FloorToFloat</span>
<p>向下舍入(去尾法),保留 n 位小数</p>
<p>向下舍入(去尾法),保留n位小数</p>
<b>函数签名:</b>
@@ -608,7 +608,7 @@ func main() {
### <span id="FloorToString">FloorToString</span>
<p>向下舍入(去尾法),保留 n 位小数,返回字符串</p>
<p>向下舍入(去尾法),保留n位小数,返回字符串</p>
<b>函数签名:</b>
@@ -1127,3 +1127,38 @@ func main() {
// 0.2
}
```
### <span id="Div">Div</span>
<p>除法运算.</p>
<b>函数签名:</b>
```go
func Div[T constraints.Float | constraints.Integer](x T, y T) float64
```
<b>示例:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/mathutil"
)
func main() {
result1 := mathutil.Div(9, 4)
result2 := mathutil.Div(1, 2)
result3 := mathutil.Div(0, 666)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
// Output:
// 2.25
// 0.5
// 0
}
```