MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / FmtFloatFromInterface

Function FmtFloatFromInterface

common/interface_to_all.go:52–65  ·  view source on GitHub ↗
(val interface{})

Source from the content-addressed store, hash-verified

50}
51
52func FmtFloatFromInterface(val interface{}) float64 {
53 if val == nil {
54 return 0
55 }
56
57 switch ret := val.(type) {
58 case float64:
59 return ret
60 case float32:
61 return float64(ret)
62 default:
63 return 0
64 }
65}
66
67func FloatToString(val float64) string {
68 float, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", val), 64)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected