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
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
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.