// ToFloat converts the given value to a float.
354774
func (ns *Namespace) ToFloat(v interface{}) (float64, error) {
	v = convertTemplateToString(v)
	return _cast.ToFloat64E(v)
}
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
	}
}
130087
func (t *Tag) Float(i int) (float64, error) {
	if t.format != FloatVal {
		return 0, t.typeErr(FloatVal)
	}
	return t.floatVals[i], nil
}
1228479
func ValueToFloat64(val Value) (float64, bool) {
	if val == nil || val.Nil() || val.Err() {
		return math.NaN(), false
	}
	switch v := val.(type) {
	case NumericValue:
		return v.Float(), true
	case StringValue:
		return StringToFloat64(v.Val())
	case BoolValue:
		// Should we co-erce bools to 0/1?
		if v.Val() {
			return float64(1), true
		}
		return float64(0), true
	}
	return math.NaN(), false
}
208395
func getFloat(unk interface{}) float64 {
	switch i := unk.(type) {
	case float64:
		return i
	case string:
		f, err := strconv.ParseFloat(i, 64)
		if err != nil || math.IsNaN(f) {
			return float64(0)
		}
		return f
	default:
		return float64(0)
	}
}
715417
func ToFloat64(v Value) (float64, error) {
	num, err := newNumeric(v)
	if err != nil {
		return 0, err
	}
	switch num.typ {
	case Int64:
		return float64(num.ival), nil
	case Uint64:
		return float64(num.uval), nil
	case Float64:
		return num.fval, nil
	}
	panic("unreachable")
}
196605
func Float(input interface{}) (output float64, err error) {

	switch castValue := input.(type) {
	case Floater:
		output = castValue.Float()
		return
	case string:
		output, err = strconv.ParseFloat(castValue, 64)
	case []byte:
		output, err = strconv.ParseFloat(string(castValue), 64)
		return
	case int:
		output = float64(castValue)
		return
	case int8:
		output = float64(castValue)
		return
	case int16:
		output = float64(castValue)
		return
	case int32:
		output = float64(castValue)
		return
	case int64:
		output = float64(castValue)
		return
	case uint:
		output = float64(castValue)
		return
	case uint8:
		output = float64(castValue)
		return
	case uint16:
		output = float64(castValue)
		return
	case uint32:
		output = float64(castValue)
		return
	case uint64:
		output = float64(castValue)
		return
	case float32:
		output = float64(castValue)
		return
	case float64:
		output = float64(castValue)
		return
	case bool:
		output = float64(0)
		if castValue {
			output = float64(1)
		}
		return
	case nil:
		output = float64(0)
		return
	default:
		err = NewCastError("Could not convert to float64")
	}
	return
}
1018553
func (t Result) Float() float64 {
	switch t.Type {
	default:
		return 0
	case True:
		return 1
	case String:
		n, _ := strconv.ParseFloat(t.Str, 64)
		return n
	case Number:
		return t.Num
	}
}
1226259
func (d *Decoder) DecodeFloat64() (float64, error) {
	c, err := d.readCode()
	if err != nil {
		return 0, err
	}
	return d.float64(c)
}
992498
func (p *point) FloatValue() (float64, error) {
	f, err := parseFloatBytes(p.it.valueBuf, 64)
	if err != nil {
		return 0, fmt.Errorf("unable to parse floating point value %q: %v", p.it.valueBuf, err)
	}
	return f, nil
}
981706
func ToFloat64(val interface{}) (float64, error) {
	switch v := val.(type) {
	case int:
		return float64(v), nil
	case int8:
		return float64(v), nil
	case int16:
		return float64(v), nil
	case int32:
		return float64(v), nil
	case int64:
		return float64(v), nil
	case float32:
		return float64(v), nil
	case float64:
		return v, nil
	case string:
		return strconv.ParseFloat(v, 64)
	case json.Number:
		return v.Float64()
	default:
		return 0, fmt.Errorf("Unhandled type: %t", v)
	}
}
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
}
478859
func asFloat(param string) float64 {

	i, err := strconv.ParseFloat(param, 64)
	panicIf(err)

	return i
}
296200
func TimeToFloat(t time.Time) float64 {
	return float64(t.Unix()) + (float64(t.Nanosecond()) / 1e9)
}
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
}
599300
func NewFloat(value string) (DataType, error) {
	returnValue := new(Float)
	v, err := strconv.ParseFloat(value, 64)
	returnValue.value = v
	return returnValue, err
}
1245655
func ConvertFloatToInt(fval float64, lowerBound, upperBound int64, tp byte) (int64, error) {
	val := RoundFloat(fval)
	if val < float64(lowerBound) {
		return lowerBound, overflow(val, tp)
	}

	if val >= float64(upperBound) {
		if val == float64(upperBound) {
			return upperBound, nil
		}
		return upperBound, overflow(val, tp)
	}
	return int64(val), nil
}