Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


DECRBY -2**63 over 0 should report out of range error #725

jokea opened this Issue · 5 comments

3 participants

redis> set a 0
redis> decrby a -9223372036854775807
(integer) 9223372036854775807
redis> set a 0
redis> decrby a -9223372036854775808
(integer) -9223372036854775808

The last decrby command should return out range error.


Not and issue, minimal value for 64bit signed int really is "-9223372036854775808".


That's true. But "0 - (-9223372036854775808)" should be 9223372036854775808,
which can't be represented as a signed 64bit value and should report out-of-range error.


@jokea a little mod could solve it ( incrDecrCommand function )

 if ((incr < 0 && oldvalue <= 0 && incr < (LLONG_MIN-oldvalue+1)) ||
        (incr > 0 && oldvalue >= 0 && incr > (LLONG_MAX-oldvalue))) {
redis> set a 0
redis> decrby a -9223372036854775808
(error) ERR increment or decrement would overflow
redis> get a


Thanks @rootslab.

Fixing it is simple, I want to make sure this is a bug and gets fixed in all redis versions.


Hi @jokea,
since it's a minor bug/fix, I think it is useful to at least indicate the point in the code where it happens, or to send a simple pull request ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.