5 ms·
In theory, computer scientists and programmers only admit the existence of 0, 1, and infinity. In practice, I've encountered the "tri-state boolean" at least t
by jerf 12y ago
In theory, computer scientists and programmers only admit the existence of 0, 1, and infinity.
In practice, I've encountered the "tri-state boolean" at least three times, completely separately, and one coworker once joyfully produced a quint-state boolean, which is to say, in practice programmers will use without restriction all sorts of strange mathematical extensions to numbers.
(A "tri-state boolean" is a boolean field that probably started life with two values but grew a third on the side instead of being upgraded cleanly. A common case is in SQL, where you can make a bool value NULL and thus have true, false, and NULL, which may end up being treated differently by only some parts of the code. Happy debugging!)
- mikeash 12y agoThis can be all sorts of fun in Objective-C, which for historical reasons has a commonly-used BOOL type which is an eight-bit integer. You're supposed to only store 0 and 1 in it and pretend the other possible values don't exist. Every so often I see some code that uses 2 as well. Once I saw some code, written far too late at night, which used a BOOL as a counter.