# INCRBYFLOAT

> Add a floating-point number to the number stored at a key.

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

```
INCRBYFLOAT key increment
```

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

`INCRBYFLOAT` adds `increment`, which may be negative and may use exponent
notation such as `2.5e3`, to the number stored at `key`. A missing key counts
as `0`. The result is stored as text with up to 17 digits after the decimal
point and trailing zeros removed, so adding `0.1` to `10.5` stores `10.6`
rather than a long binary rounding artefact. The key keeps its time to live.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Always | Bulk string: the new value | Bulk string |

The new value is a bulk string in RESP3 too, not a double.

Errors:

- `ERR value is not a valid float` when `increment` or the stored value is
  not a number.
- `ERR increment would produce NaN or Infinity` when `increment` or the
  result is not finite.
- `WRONGTYPE` when the key holds a value that is not a string.

## Examples

```
127.0.0.1:6379> SET price 10.50
OK
127.0.0.1:6379> INCRBYFLOAT price 0.1
"10.6"
127.0.0.1:6379> INCRBYFLOAT price -5
"5.6"
127.0.0.1:6379> SET total 1e3
OK
127.0.0.1:6379> INCRBYFLOAT total 2.5e2
"1250"
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[INCRBY](https://docs.hotkv.com/commands/incrby/index.md), [INCR](https://docs.hotkv.com/commands/incr/index.md),
[HINCRBYFLOAT](https://docs.hotkv.com/commands/hincrbyfloat/index.md)