(val float64, places int)
| 72 | } |
| 73 | |
| 74 | func 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) |
| 103 | func ParseTitleFromMdHtml(html string) (title string) { |
nothing calls this directly
no outgoing calls
no test coverage detected