// parseFloatRange handles ZRANGEBYSCORE floats. They are inclusive unless the
// string starts with '('
328089
func parseFloatRange(s string) (float64, bool, error) {
	if len(s) == 0 {
		return 0, false, nil
	}
	inclusive := true
	if s[0] == '(' {
		s = s[1:]
		inclusive = false
	}
	f, err := strconv.ParseFloat(s, 64)
	return f, inclusive, err
}
539870
func (p *parser) parseFieldValue(s string, msgName string, field *descriptor.FieldDescriptorProto) (interface{}, error) {
	switch field.GetType() {

	case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
		return strconv.ParseFloat(s, 64)

	case descriptor.FieldDescriptorProto_TYPE_FLOAT:
		x, err := strconv.ParseFloat(s, 32)
		return float32(x), err

	case
		descriptor.FieldDescriptorProto_TYPE_INT32,
		descriptor.FieldDescriptorProto_TYPE_SFIXED32,
		descriptor.FieldDescriptorProto_TYPE_SINT32:

		x, err := strconv.ParseInt(s, 10, 32)
		return int32(x), err

	case descriptor.FieldDescriptorProto_TYPE_INT64,
		descriptor.FieldDescriptorProto_TYPE_SFIXED64,
		descriptor.FieldDescriptorProto_TYPE_SINT64:

		return strconv.ParseInt(s, 10, 64)

	case descriptor.FieldDescriptorProto_TYPE_UINT32, descriptor.FieldDescriptorProto_TYPE_FIXED32:
		x, err := strconv.ParseUint(s, 10, 32)
		return uint32(x), err

	case descriptor.FieldDescriptorProto_TYPE_UINT64, descriptor.FieldDescriptorProto_TYPE_FIXED64:
		return strconv.ParseUint(s, 10, 64)

	case descriptor.FieldDescriptorProto_TYPE_BOOL:
		return strconv.ParseBool(s)

	case descriptor.FieldDescriptorProto_TYPE_STRING:
		return s, nil

	case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
		return nil, fmt.Errorf(
			"%s.%s is a message field. Specify its field values, not the message itself",
			msgName, field.GetName())

	case descriptor.FieldDescriptorProto_TYPE_BYTES:
		return hex.DecodeString(s)

	case descriptor.FieldDescriptorProto_TYPE_ENUM:
		obj, err := p.resolve(field.GetTypeName())
		if err != nil {
			return nil, err
		}
		enum, ok := obj.(*descriptor.EnumDescriptorProto)
		if !ok {
			return nil, fmt.Errorf(
				"field %s.%s is declared as of type enum %s, but %s is not an enum",
				msgName, field.GetName(),
				field.GetTypeName(), field.GetTypeName(),
			)
		}
		return parseEnum(enum, s)

	default:
		return nil, fmt.Errorf("field type %s is not supported", field.GetType())
	}
}
750736
func (c *Context) DepthRange(zNear, zFar float64) {
	c.Call("depthRange", zNear, zFar)
}
389285
func (c *Client) ZRange(key string, start int, stop int, withscores bool) ([]string, error) {
	var v interface{}
	var err error
	if withscores == true {
		v, err = c.execWithKey(true, "ZRANGE", key, start, stop, "WITHSCORES")
	} else {
		v, err = c.execWithKey(true, "ZRANGE", key, start, stop)
	}
	if err != nil {
		return nil, err
	}
	return iface2vstr(v), nil
}
578141
func (k *Key) RangeFloat64(defaultVal, min, max float64) float64 {
	val := k.MustFloat64()
	if val < min || val > max {
		return defaultVal
	}
	return val
}
1041466
func (conf *Config) GetPartitionRange(partNum, totalParts int) (start int, end int) {
	perPart := conf.InitialBuckets / totalParts
	leftOver := conf.InitialBuckets % totalParts
	start = partNum * perPart
	if leftOver > 0 {
		if partNum == 0 {
			end++
		} else if partNum < leftOver {
			start += partNum
			end++
		} else {
			start += leftOver
		}
	}
	end += start + perPart
	if partNum == totalParts-1 {
		end = conf.InitialBuckets
	}
	return
}
382075
func (c *asyncClient) Zrangebyscore(arg0 string, arg1 float64, arg2 float64) (result FutureBytesArray, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(fmt.Sprintf("%e", arg1))
	arg2bytes := []byte(fmt.Sprintf("%e", arg2))

	var resp *PendingResponse
	resp, err = c.conn.QueueRequest(&ZRANGEBYSCORE, [][]byte{arg0bytes, arg1bytes, arg2bytes})
	if err == nil {
		result = resp.future.(FutureBytesArray)
	}
	return result, err

}
213207
func parseAccountBalanceNtfnParams(params []json.RawMessage) (account string,
	balance btcutil.Amount, confirmed bool, err error) {

	if len(params) != 3 {
		return "", 0, false, wrongNumParams(len(params))
	}

	// Unmarshal first parameter as a string.
	err = json.Unmarshal(params[0], &account)
	if err != nil {
		return "", 0, false, err
	}

	// Unmarshal second parameter as a floating point number.
	var fbal float64
	err = json.Unmarshal(params[1], &fbal)
	if err != nil {
		return "", 0, false, err
	}

	// Unmarshal third parameter as a boolean.
	err = json.Unmarshal(params[2], &confirmed)
	if err != nil {
		return "", 0, false, err
	}

	// Bounds check amount.
	bal, err := btcutil.NewAmount(fbal)
	if err != nil {
		return "", 0, false, err
	}

	return account, bal, confirmed, nil
}
1142218
func parseFloatBytes(b []byte, bitSize int) (float64, error) {
	s := unsafeBytesToString(b)
	return strconv.ParseFloat(s, bitSize)
}
325809
func (ctx *context) PostValueFloat64(name string) (float64, error) {
	v := ctx.PostValue(name)
	if v == "" {
		return -1, errUnableToFindPostValue.Format(name)
	}
	return strconv.ParseFloat(v, 64)
}
139851
func (p Properties) Float(key string, def float64) float64 {
	if v, found := p[key]; found {
		if b, err := strconv.ParseFloat(v, 64); err == nil {
			return b
		}
	}
	return def
}
436077
func AlphaStringRange(min, max int) (string, error) {
	return StringRange(min, max, Alphanumeric)
}
779036
func floatStringToNs(s string) (int64, error) {
	const zeros = "000000000"
	if point := strings.IndexRune(s, '.'); point >= 0 {
		tail := s[point+1:]
		if fill := 9 - len(tail); fill < 0 {
			tail = tail[:9]
		} else {
			tail += zeros[:fill]
		}
		s = s[:point] + tail
	} else if len(s) > 0 { // Make sure empty string produces an error
		s += zeros
	}
	return strconv.ParseInt(s, 10, 64)
}
477320
func StringToFloat64(from string) (float64, error) {
	val, err := strconv.ParseFloat(from, 64)
	return val, err
}
741966
func MustParseFloat(s string, bitSize int) float64 {
	// nolint: gosec
	i, _ := strconv.ParseFloat(s, bitSize)
	return i
}
893007
func (p *Params) Float32(key string) (float32, error) {
	v, err := strconv.ParseFloat(p.Get(key), 32)
	return float32(v), err
}
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)
	}
}