I received this question from a student:
What is happening when I add to a long infinty in kdb?
Perhaps someone can answer this one?
Short answer: Assuming that it is a positive number, then it would overflow (and most likely end up as a negative value).
Long answer: kdb+ represents infinity as the largest positive integer (in 2’s complement) of that datatype. So for long (64 bits) that would be 2^63-1. This can easily be verified:
`
0W – 1 = 0111 1111 1111 … 1110 = 2^63-2 = 9223372036854775806
0W = 0111 1111 1111 … 1111 = 2^63-1 = 0W
0W + 1 = 1000 0000 0000 … 0000 = -2^63 = 0N
0W + 2 = 1000 0000 0000 … 0001 = -2^63+1 = -0W
0W + 3 = 1000 0000 0000 … 0010 = -2^63+2 = -9223372036854775806
`