# HINCRBYFLOAT

> Add a floating-point number to the value of a hash field.

URL: https://docs.hotkv.com/commands/hincrbyfloat/

```
HINCRBYFLOAT key field increment
```

- Group: Hash
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`HINCRBYFLOAT` adds `increment` to the number stored in `field` of the hash at
`key` and returns the new value. A missing key or field starts at `0`. Use a
negative `increment` to subtract. The field keeps any time to live it already
had.

The increment can be written as a decimal (`1.5`), with an exponent (`2e3`),
or as an integer. The result is stored as a decimal string without trailing
zeros.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Bulk string: the value after the increment | Bulk string |

Errors:

- `ERR value is not a valid float` if `increment` is not a number.
- `WRONGTYPE` if `key` holds a value that is not a hash.
- `ERR hash value is not a valid float` if the field holds something that is
  not a number, or if the result would be infinite or not a number.

## Examples

```
127.0.0.1:6379> HSET item:7 price 10.5
(integer) 1
127.0.0.1:6379> HINCRBYFLOAT item:7 price 0.25
"10.75"
127.0.0.1:6379> HINCRBYFLOAT item:7 price -0.75
"10"
127.0.0.1:6379> HINCRBYFLOAT item:7 weight 2e3
"2000"
```

## Compatibility

Same arguments and successful replies as Redis 7.4 and Valkey 8. The error
text differs: where Redis and Valkey reply `ERR hash value is not a float`,
HotKV replies `ERR hash value is not a valid float`, and HotKV uses that same
error when the increment or the result would be infinite (Redis and Valkey
reply `ERR value is NaN or Infinity` or
`ERR increment would produce NaN or Infinity`).

## See also

[HINCRBY](https://docs.hotkv.com/commands/hincrby/index.md), [HSET](https://docs.hotkv.com/commands/hset/index.md), [HGET](https://docs.hotkv.com/commands/hget/index.md),
[INCRBYFLOAT](https://docs.hotkv.com/commands/incrbyfloat/index.md)