MCPcopy Create free account
hub / github.com/araddon/qlbridge / StringToFloat64

Function StringToFloat64

value/coerce.go:369–383  ·  view source on GitHub ↗

StringToFloat64 converts a string to a float includes replacement of $ and other monetary format identifiers. May return math.NaN

(s string)

Source from the content-addressed store, hash-verified

367// includes replacement of $ and other monetary format identifiers.
368// May return math.NaN
369func StringToFloat64(s string) (float64, bool) {
370 if s == "" {
371 return math.NaN(), false
372 }
373 f, err := strconv.ParseFloat(s, 64)
374 if err == nil {
375 return f, true
376 }
377 s = intStrReplacer.Replace(s)
378 f, err = strconv.ParseFloat(s, 64)
379 if err == nil {
380 return f, true
381 }
382 return math.NaN(), false
383}
384
385// Some strings we are trying to convert into Numbers are messy
386// $3.12 etc, lets replace them and retry conversion again

Callers 6

avgEvalFunction · 0.92
sumEvalFunction · 0.92
numberNodeToValueFunction · 0.92
NumberValueMethod · 0.85
ValueToFloat64Function · 0.85
TestValueToFloatFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestValueToFloatFunction · 0.68