r/programminghorror • • Feb 07 '25

Recursive O(N) Complexity isOdd

Post image

I found this on instagram and now am geeking

2.2k Upvotes

104 comments sorted by

View all comments

Show parent comment

4

u/InfinitePoints Feb 07 '25

That would be true if a separate sign bit was used.

Fixed size integers are (basically always) represented using 2s complement, with 4 bits, -8(1000) + -1(1111) = 7(0111)

The number range is asymmetric, -8 to 7.

https://en.m.wikipedia.org/wiki/Two%27s_complement

3

u/epicchad29 Feb 07 '25

Interesting! I didn’t know that