# Why is division of a negative number by 0 not the minimum number? [duplicate]

Related to Why does vim allow to divide by zero, what's going on here?

``````:let a=-42/0
:echo a
-2147483647

:let b=a - 1
:echo b
-2147483648
``````
• @Nobe4's answer on the linked question is more than sufficient to answer this question, so this question is now a duplicate. Sep 3, 2015 at 14:42

It is because vim represents the signed integers on 32 bits which makes that `-2147483648` actually is the smallest number in Vim and not `-2147483647` as you could think.

``````let foo = -2147483647
echo foo - 1
=> -2147483648

let foo = -2147483648
echo foo - 1
=> 2147483647
``````

On 32 bits the max value of an integer is `2^31-1` when the min value is `-2^31`. For an explanation of this different values see this wiki page about the two complement in the representation of signed integers.

• See my edition on the linked question :) : `-2147483648` is used for representing `NaN` Sep 3, 2015 at 6:31
• @statox: this answer does not explain why -X/0 is -2147483647 instead of -2147483648. Sep 3, 2015 at 14:44