Hacker News new | ask | show | jobs
by mbel 863 days ago
It's not. 0x8000 is the smallest (-32,768) integer that can be represented with 16-bits and two's complement.
2 comments

abs() of this value also happens to exceed the maximum positive value. Which means that in C, a simple negation can cause signed integer overflow -(-32768), and therefore UB.
Yeah, I think it is funny that in a standard binary, it would replace negative zero and makes some sense. In two's complement, it replaces the minimum value.

Fair that sentinel value is sentinel value, I suppose. But it is not like it is not a known and unique number in that encoding.