4 ms·
I had no idea that 1111..1111 was the smallest negative integer as opposed to 1000..0001. How did I not know that after nearly 25 years of programming? I must
by TheMagicHorsey 3y ago
I had no idea that 1111..1111 was the smallest negative integer as opposed to 1000..0001.
How did I not know that after nearly 25 years of programming? I must be dumb.
- deleted 3y ago[deleted]
- detrites 3y agoYou just didn't happen to hit that particular thing in that time, there'll be a long list like that for all coders. The subset of coding and computer science anyone interacts with will always be small compared to the entirety of the field.
- jwilk 3y ago1111…1111 is −1. 1000…0000 is the minimum.
- FreeFull 3y agoHaving 1000...0001 represent -1 would be sign-magnitude representation. Having 1111...1111 be -1 is two's complement. Computers usually use two's complement for integers, because it makes addition and multiplication really easy to implement. Floating point actually is closer to sign-magnitude, though.
- yencabulator 3y agoAnd sign-magnitude representation would lead to +0 and -0 being two different bit patterns, which would mean == on integers couldn't be a direct byte comparison anymore. Undesirable.
- pwdisswordfishc 3y agoYou learn something new every day! The lowest negative integer is still 1000…0000, though.
- duckqlz 3y agoI'm confused by what you are saying? 111..11111 = -1 (for Nbit) 100..00000 = -2147483648 (for 32bit) Therefore 11...1 is smaller than 100...01? Maybe I am dumb and missing something? Can anyone help?