merge
This commit is contained in:
parent
c106a01a28
commit
4a1147b1af
@ -217,3 +217,26 @@ func filterForDigits(str string) int {
|
||||
s, _ := strconv.Atoi(numStr)
|
||||
return s
|
||||
}
|
||||
|
||||
func getFloat64(unknown interface{}) (float64, error) {
|
||||
switch i := unknown.(type) {
|
||||
case float64:
|
||||
return i, nil
|
||||
case float32:
|
||||
return float64(i), nil
|
||||
case int64:
|
||||
return float64(i), nil
|
||||
case int32:
|
||||
return float64(i), nil
|
||||
case int:
|
||||
return float64(i), nil
|
||||
case uint64:
|
||||
return float64(i), nil
|
||||
case uint32:
|
||||
return float64(i), nil
|
||||
case uint:
|
||||
return float64(i), nil
|
||||
default:
|
||||
return math.NaN(), errors.New("Non-numeric type could not be converted to float")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user