// CastFloatValue casts a float to datapoint Value
481529
func CastFloatValue(value interface{}) (metricValue Value, err error) {
	switch val := value.(type) {
	case float64:
		metricValue = floatWire(val)
	case float32:
		metricValue = floatWire(float64(val))
	default:
		err = fmt.Errorf("unknown metric value type %T", val)
	}
	return
}
1253018
func Float(v float64) *datatypes.Float64 {
	r := datatypes.Float64(v)
	return &r
}
124457
func TryToFloat32(i interface{}) (r float32, err error) {
	switch t := i.(type) {
	case float32:
		r = t
	case *float32:
		r = *t
	case float64:
		r = float32(t)
	case int:
		r = float32(t)
	case int8:
		r = float32(t)
	case int16:
		r = float32(t)
	case int32:
		r = float32(t)
	case int64:
		r = float32(t)
	case bool:
		if t {
			r = 1
		}
	case string:
		var v float64
		if v, err = strconv.ParseFloat(t, 32); err == nil {
			r = float32(v)
		}
	default:
		err = castError(i, "float32")
	}
	return
}
327520
func (bd *BinaryDecoder) ReadFloat() (float32, error) {
	var float float32
	if err := checkEOF(bd.buf, bd.pos, 4); err != nil {
		return float, err
	}
	bits := binary.LittleEndian.Uint32(bd.buf[bd.pos : bd.pos+4])
	float = math.Float32frombits(bits)
	bd.pos += 4
	return float, nil
}
1046010
func (v *value) AsFloat64(dv float64) float64 {
	if v.IsUndefined() {
		return dv
	}
	switch tv := v.raw.(type) {
	case string:
		f, err := strconv.ParseFloat(tv, 64)
		if err != nil {
			return dv
		}
		return f
	case int:
		return float64(tv)
	case float64:
		return tv
	case bool:
		if tv {
			return 1.0
		}
		return 0.0
	}
	return dv
}
328285
func (c *Distconf) Float(key string, defaultVal float64) *Float {
	c.grabInfo(key)
	s := &floatConf{
		defaultVal: defaultVal,
		Float: Float{
			currentVal: math.Float64bits(defaultVal),
		},
	}
	// Note: in race conditions 's' may not be the thing actually returned
	ret, okCast := c.createOrGet(key, s).(*floatConf)
	if !okCast {
		c.Logger.Log(logkey.DistconfKey, key, "Registering key with multiple types!  FIX ME!!!!")
		return nil
	}
	return &ret.Float
}
1303773
func (v *variable) floatValue() float64 {
	f, err := strconv.ParseFloat(v.value, 64)
	if err != nil {
		panic("unexpected value " + v.value + " for float ")
	}
	return f
}
970911
func floatFromInterface(val interface{}) (float64, error) {
	switch val.(type) {
	case float64:
		return val.(float64), nil
	case int:
		return float64(val.(int)), nil
	case string:
		fval, err := strconv.ParseFloat(val.(string), 64)
		if err == nil {
			return fval, nil
		}
	}
	return 0.0, fmt.Errorf("Expected numeric value for Float, got \"%v\"\n", val)
}
426478
func (be *BinaryEncoder) WriteFloat(x float32) {
	bytes := make([]byte, 4)
	binary.LittleEndian.PutUint32(bytes, math.Float32bits(x))
	_, _ = be.buffer.Write(bytes)
}
606808
func NewFloatValue(t int64, v float64) Value {
	return FloatValue{unixnano: t, value: v}
}
1021511
func (buf *Float32Buffer) AsFloatBuffer() *FloatBuffer {
	newB := &FloatBuffer{}
	newB.Data = make([]float64, len(buf.Data))
	for i := 0; i < len(buf.Data); i++ {
		newB.Data[i] = float64(buf.Data[i])
	}
	newB.Format = &Format{
		NumChannels: buf.Format.NumChannels,
		SampleRate:  buf.Format.SampleRate,
	}
	return newB
}
705839
func (f *Feature) PropertyFloat64(key string) (float64, error) {
	if i, ok := (f.Properties[key]).(float64); ok {
		return i, nil
	}
	return 0, fmt.Errorf("type assertion of `%s` to float64 failed", key)
}
354774
func (ns *Namespace) ToFloat(v interface{}) (float64, error) {
	v = convertTemplateToString(v)
	return _cast.ToFloat64E(v)
}
743337
func ToFloat64(v interface{}) float64 {
	if str, ok := v.(string); ok {
		return strToFloat64(str)
	}

	val := reflect.Indirect(reflect.ValueOf(v))
	switch val.Kind() {
	case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
		return float64(val.Int())
	case reflect.Uint8, reflect.Uint16, reflect.Uint32:
		return float64(val.Uint())
	case reflect.Uint, reflect.Uint64:
		return float64(val.Uint())
	case reflect.Float32, reflect.Float64:
		return val.Float()
	case reflect.Bool:
		if val.Bool() {
			return 1
		}
		return 0
	default:
		return 0
	}
}
372593
func (d *defaulter) AsFloat64(v Valuer, dv float64) float64 {
	value, err := v.Value()
	if err != nil {
		d.logValuerError(err)
		return dv
	}
	fvalue, err := strconv.ParseFloat(value, 64)
	if err != nil {
		d.logFormatError("float64", err)
		return dv
	}
	return fvalue
}
1364334
func keyFloat(v reflect.Value) (f float64, ok bool) {
	switch v.Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return float64(v.Int()), true
	case reflect.Float32, reflect.Float64:
		return v.Float(), true
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
		return float64(v.Uint()), true
	case reflect.Bool:
		if v.Bool() {
			return 1, true
		}
		return 0, true
	}
	return 0, false
}
1044210
func ToFloat(data interface{}) (float64, bool) {
	switch typed := data.(type) {
	case float64:
		return typed, true
	case float32:
		return float64(typed), true
	default:
		if n, ok := ToInt(data); ok {
			return float64(n), true
		}
		return 0, false
	}
}