// GetFloat32 same as `Get` but returns its float32 representation,
// if key doesn't exist then it returns -1 and a non-nil error.
196391
func (s *Session) GetFloat32(key string) (float32, error) {
	v := s.Get(key)

	if vfloat32, ok := v.(float32); ok {
		return vfloat32, nil
	}

	if vfloat64, ok := v.(float64); ok {
		return float32(vfloat64), nil
	}

	if vint, ok := v.(int); ok {
		return float32(vint), nil
	}

	if vstring, sok := v.(string); sok {
		vfloat64, err := strconv.ParseFloat(vstring, 32)
		if err != nil {
			return -1, err
		}
		return float32(vfloat64), nil
	}

	return -1, fmt.Errorf(errFindParse, "float32", key)
}
208264
func (c *Context) GetFloat64(key string) (f64 float64) {
	if val, ok := c.Get(key); ok && val != nil {
		f64, _ = val.(float64)
	}
	return
}
541406
func (f *Flash) GetFloat64(key string) float64 {
	r, _ := f.Get(key).(float64)
	return r
}
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
}
1225403
func GetFloat(data []byte, keys ...string) (val float64, err error) {
	v, t, _, e := Get(data, keys...)

	if e != nil {
		return 0, e
	}

	if t != Number {
		return 0, fmt.Errorf("Value is not a number: %s", string(v))
	}

	return ParseFloat(v)
}
1352039
func ReadFloatFrom(data []byte) (Argument, int64, error) {
	var f Float
	if err := binary.Read(bytes.NewReader(data), byteOrder, &f); err != nil {
		return nil, 0, errors.Wrap(err, "read float argument")
	}
	return f, 4, nil
}
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")
}
453663
func (c *Config) Float64(key string) (float64, error) {
	return strconv.ParseFloat(c.get(key), 64)
}
674898
func Float32() gopter.Gen {
	return gopter.CombineGens(
		Int32Range(0, 1),
		Int32Range(0, 0xfe),
		Int32Range(0, 0x7fffff),
	).Map(func(values []interface{}) float32 {
		sign := uint32(values[0].(int32))
		exponent := uint32(values[1].(int32))
		mantissa := uint32(values[2].(int32))

		return math.Float32frombits((sign << 31) | (exponent << 23) | mantissa)
	}).WithShrinker(Float32Shrinker)
}
1286940
func (p *Params) MustFloat32(key string, defaults ...float32) float32 {
	r, err := strconv.ParseFloat(p.Get(key), 32)
	if len(defaults) > 0 && err != nil {
		return defaults[0]
	}
	return float32(r)
}
125157
func (v *Float) Get() float64 {
	v.mu.Lock()
	f := v.f
	v.mu.Unlock()
	return f
}
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
}
879939
func (w *ByteWriter) WriteFloat32(val float32, offset int) (int, error) {
	return w.WriteVal(val, offset)
}
1321066
func ConvertFloat32(str string) (float32, error) {
	f, err := strconv.ParseFloat(str, 32)
	if err != nil {
		return 0, err
	}
	return float32(f), nil
}
1017470
func (d *Datum) GetFloat32() float32 {
	return float32(math.Float64frombits(uint64(d.i)))
}
187810
func (c *Config) GetFloat64(key string) (f float64) {
	f, _ = c.GetFloat64Ok(key)
	return
}
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
}