// EncodeFloat encodes a float v into a byte slice which can be sorted lexicographically later.
// EncodeFloat guarantees that the encoded value is in ascending order for comparison.
494377
func EncodeFloat(b []byte, v float64) []byte {
	u := encodeFloatToCmpUint64(v)
	return EncodeUint(b, u)
}
859550
func (d *MyDecimal) ToFloat64() (float64, error) {
	f, err := strconv.ParseFloat(d.String(), 64)
	if err != nil {
		err = ErrOverflow
	}
	return f, err
}
522559
func toFloat64(v interface{}) float64 {
	if str, ok := v.(string); ok {
		iv, err := strconv.ParseFloat(str, 64)
		if err != nil {
			return 0
		}
		return iv
	}

	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() == true {
			return 1
		}
		return 0
	default:
		return 0
	}
}
1256790
func (enc *Encoder) FloatKey(key string, v float64) {
	enc.Float64Key(key, v)
}
949570
func DecodeFloatDesc(b []byte) ([]byte, float64, error) {
	b, u, err := DecodeUintDesc(b)
	return b, decodeCmpUintToFloat(u), errors.Trace(err)
}
425650
func (v BytesValue) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}

	return raw.encodeBytes(w, []byte(v))
}
875147
func (Encoder) AppendFloat64(dst []byte, val float64) []byte {
	return appendFloat(dst, val, 64)
}
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
}
426478
func (be *BinaryEncoder) WriteFloat(x float32) {
	bytes := make([]byte, 4)
	binary.LittleEndian.PutUint32(bytes, math.Float32bits(x))
	_, _ = be.buffer.Write(bytes)
}
709097
func (dec *Decoder) SliceFloat64(s *[]float64) error {
	err := dec.Array(DecodeArrayFunc(func(dec *Decoder) error {
		var i float64
		if err := dec.Float64(&i); err != nil {
			return err
		}
		*s = append(*s, i)
		return nil
	}))

	if err != nil {
		return err
	}
	return 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
}
1157808
func (e *Encoder) Encode(v interface{}) error {
	val := reflect.ValueOf(v)
	return e.encode(val)
}
634819
func ToFloat(value interface{}) (float64, error) {
	v := reflect.ValueOf(value)
	switch v.Kind() {
	case reflect.Float32, reflect.Float64:
		return v.Float(), nil
	}
	return 0, fmt.Errorf("cannot convert %v to float64", v.Kind())
}
473298
func (enc *Encoder) SliceFloat64Key(k string, s []float64) {
	enc.ArrayKey(k, EncodeArrayFunc(func(enc *Encoder) {
		for _, i := range s {
			enc.Float64(i)
		}
	}))
}
1303554
func (d Data) GetFloat(key string) float64 {
	if !d.KeyExists(key) || len(d.Values[key]) == 0 {
		return 0.0
	}
	str := d.Get(key)
	if result, err := strconv.ParseFloat(str, 64); err != nil {
		panic(err)
	} else {
		return result
	}
}
256121
func (enc *Encoder) EncodeFloat32(n float32) error {
	if enc.isPooled == 1 {
		panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
	}
	_, _ = enc.encodeFloat32(n)
	_, err := enc.Write()
	if err != nil {
		return err
	}
	return nil
}
1087356
func (w *ByteWriter) WriteFloat64(val float64, offset int) (int, error) {
	return w.WriteVal(val, offset)
}