INCRBYFLOAT adds a decimal number, such as 1.25, to a value in Valkey®. A negative number subtracts. This guide changes a temperature reading.
Type the commands at the valkey-cli prompt. To open it, run valkey-cli in a terminal.
Note: Every command and output on this page is real, run on Valkey 9.2 on an Apple silicon Mac with macOS 26.
Syntax
INCRBYFLOAT key increment
key: the value to change. If it doesn’t exist, Valkey starts it at 0.increment: the decimal number to add. A negative number subtracts.
From the INCRBYFLOAT documentation (opens in a new tab).
Step 1: Save a Starting Value
SET temperature 20.5
OK
Step 2: Add a Decimal
INCRBYFLOAT temperature 1.25
"21.75"
The reply is the new value, in double quotes, because Valkey saves the result as text.
Step 3: Subtract with a Negative Number
INCRBYFLOAT temperature -3
"18.75"
GET temperature
"18.75"
Note: Not every decimal comes back this short. On a Mac with Apple silicon, adding 9.99 replies 9.99000000000000021: Fixed: Valkey INCRBYFLOAT Returns 9.99000000000000021 Instead of 9.99 on macOS explains why, and how to keep money exact.

Clean Up
DEL temperature
(integer) 1
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Adding prices such as 9.99 | On a Mac the reply can show extra digits | Count whole cents with INCRBY |
| Looking for a DECRBYFLOAT command | There isn’t one | Pass a negative number to INCRBYFLOAT |
FAQ
Can INCRBYFLOAT work on a whole number?
Yes. 20 and 20.5 both work, and the result drops any zeros at the end, so 21.0 comes back as 21, as the documentation (opens in a new tab) explains.
Does the key keep its expiry?
Yes. INCRBYFLOAT changes only the value.
Conclusion
INCRBYFLOAT key increment adds a decimal and replies with the new value. Use a negative number to subtract.
Related
- Valkey Tutorial — Part 4: Strings and Counters
- Fixed: Valkey INCRBYFLOAT Returns 9.99000000000000021 Instead of 9.99 on macOS
Additional Resources
Valkey® is a registered trademark of LF Projects, LLC. Redis® is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Other names mentioned are trademarks of their respective owners. JD Bots isn’t affiliated with the Valkey project, LF Projects or Redis Ltd., and isn’t endorsed, supported or certified by them.
0 comments