MCPcopy Create free account
hub / github.com/TruthHun/BookStack / Round

Function Round

utils/file.go:74–100  ·  view source on GitHub ↗
(val float64, places int)

Source from the content-addressed store, hash-verified

72}
73
74func Round(val float64, places int) float64 {
75 var t float64
76 f := math.Pow10(places)
77 x := val * f
78 if math.IsInf(x, 0) || math.IsNaN(x) {
79 return val
80 }
81 if x >= 0.0 {
82 t = math.Ceil(x)
83 if (t - x) > 0.50000000001 {
84 t -= 1.0
85 }
86 } else {
87 t = math.Ceil(-x)
88 if (t + x) > 0.50000000001 {
89 t -= 1.0
90 }
91 t = -t
92 }
93 x = t / f
94
95 if !math.IsInf(x, 0) {
96 return x
97 }
98
99 return t
100}
101
102//从md的html文件中提取文章标题(从h1-h6)
103func ParseTitleFromMdHtml(html string) (title string) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected