// GetFloat from hprose context
420349
func (context *BaseContext) GetFloat(
	key string, defaultValue ...float64) float64 {
	if value, ok := context.userData[key]; ok {
		if value, ok := value.(float64); ok {
			return value
		}
	}
	if len(defaultValue) > 0 {
		return defaultValue[0]
	}
	return 0
}
556561
func ToFloat(value interface{}) float64 {
	if result := ToString(value); result == "" {
		return 0
	} else if i, err := strconv.ParseFloat(result, 64); err == nil {
		return i
	} else {
		panic("failed to parse float: " + result)
	}
}
1256073
func (g *Graph) GetFloat64(path string) (float64, error) {

	if len(path) == 0 {
		return g.Float64(), nil
	}

	i := g.Get(path)
	if i == nil {
		return 0, errors.New("not found")
	}
	if i.Len() == 0 {
		return 0, errors.New("Get() design error: not subnodes")
	}
	j, ok := _float64f(i.Out[0].This)
	if !ok {
		return 0, errors.New("not a number")
	}
	return j, nil
}
92577
func parseIntFloat(desc string) (string, interface{}) {
	// parse for ints
	i := 0
	for i < len(desc) {
		if desc[i] < '0' || desc[i] > '9' {
			break
		}
		i++
	}
	if i == 0 {
		return "", nil
	}

	intVal := int(0)
	_, err := fmt.Sscanf(desc[:i], "%d", &intVal)
	if err != nil {
		return "", nil
	}
	if len(desc) == i {
		return desc[:i], intVal
	}
	if desc[i] != '.' {
		return desc[:i], intVal
	}

	// parse for floats
	i++
	if i == len(desc) {
		return desc[:i], float64(intVal)
	}

	j := i
	for i < len(desc) {
		if desc[i] < '0' || desc[i] > '9' {
			break
		}
		i++
	}
	if j == i {
		return desc[:i], float64(intVal)
	}

	f := float64(0)
	if _, err = fmt.Sscanf(desc[:i], "%f", &f); err != nil {
		return "", nil
	}
	return desc[:i], f
}
360232
func (ec *Envcfg) GetFloat(key string, bitSize int) float64 {
	f, _ := strconv.ParseFloat(ec.GetKey(key), bitSize)
	return f
}
1120486
func decodeFloat(rd *bufio.Reader) (string, Float, error) {
	// name
	name, err := readCstring(rd)
	if err != nil {
		return "", Float(0), err
	}

	// value
	b := make([]byte, 8)
	_, err = io.ReadFull(rd, b)
	if err != nil {
		return "", Float(0), err
	}
	var u uint64
	u += uint64(b[7]) << 56
	u += uint64(b[6]) << 48
	u += uint64(b[5]) << 40
	u += uint64(b[4]) << 32
	u += uint64(b[3]) << 24
	u += uint64(b[2]) << 16
	u += uint64(b[1]) << 8
	u += uint64(b[0])
	return name, Float(math.Float64frombits(u)), nil
}
1063092
func AsFloat(x Value) (f float64, ok bool) {
	switch x := x.(type) {
	case Float:
		return float64(x), true
	case Int:
		return float64(x.Float()), true
	}
	return 0, false
}
208264
func (c *Context) GetFloat64(key string) (f64 float64) {
	if val, ok := c.Get(key); ok && val != nil {
		f64, _ = val.(float64)
	}
	return
}
376369
func (me *DefaultAdapter) LiteralFloat(buf *SqlBuilder, f float64) error {
	if buf.IsPrepared {
		return me.PlaceHolderSql(buf, f)
	}
	buf.WriteString(strconv.FormatFloat(f, 'f', -1, 64))
	return nil
}
1027258
func (c *IniConfigContainer) DefaultFloat(key string, defaultval float64) float64 {
	v, err := c.Float(key)
	if err != nil {
		return defaultval
	}
	return v
}
1103523
func coerceToFloat(unk interface{}) (float64, error) {
	switch i := unk.(type) {
	case float64:
		if math.IsNaN(i) {
			return i, errors.New("value was NaN")
		}
		return i, nil
	case float32:
		return float64(i), nil
	case int:
		return float64(i), nil
	case int32:
		return float64(i), nil
	case int64:
		return float64(i), nil
	case uint:
		return float64(i), nil
	case uint32:
		return float64(i), nil
	case uint64:
		return float64(i), nil
	default:
		return math.NaN(), fmt.Errorf("value %q could not be coerced to float64", i)
	}
}
1245253
func (primative *Primative) AsFloat() (float64, error) {
	switch val := primative.value.(type) {
	case bool:
		floatVal := float64(0)
		if val {
			floatVal = float64(1)
		}

		return floatVal, nil
	case float64:
		return val, nil
	case int64:
		return float64(val), nil
	case string:
		return strconv.ParseFloat(val, 64)
	}

	msg := fmt.Sprintf("Could not convert value %s to type FLOAT", primative.value)
	return 0, errors.New(msg)
}
368472
func (a *Attribute) GetFloat() (value float64, ok bool) {
	if a.Float == nil {
		return 0.0, false
	}

	return *a.Float, true
}
408329
func (md *MobileDetect) VersionFloat(propertyName interface{}) float64 {
	switch propertyName.(type) {
	case string:
		return md.properties.versionFloatName(propertyName.(string), md.userAgent)
	case int:
		return md.VersionFloatKey(propertyName.(int))
	}
	return 0.0
}
1127035
func (c *Client) IncrByFloat(key string, increment float64) (string, error) {
	var ret string
	err := c.command(
		&ret,
		[]byte("INCRBYFLOAT"),
		[]byte(key),
		to.Bytes(increment),
	)
	return ret, err
}
654741
func (section *Section) GetFloat(name string) (float64, error) {
	value, err := section.Get(name)
	if err != nil {
		return float64(0), err
	}

	switch value.(type) {
	case *Primative:
		return value.(*Primative).AsFloat()
	}

	return float64(0), errors.New("could not convert non-primative value to float")
}
579244
func AsFloat(d DataType) (float64, bool) {
	value, ok := d.Value().(float64)
	return value, ok
}