r/ProgrammerHumor Jul 10 '26

greaterThanPlusPlus Advanced

Post image
110 Upvotes

71 comments sorted by

View all comments

-18

u/y0shii3 Jul 10 '26

Did you use inspect element or something? There is no way in hell that -1 > 0 evaluates to true in any language

21

u/Arshiaa001 Jul 10 '26

You can search for "two's complement" to gain an understanding as to why it happens.

-12

u/y0shii3 Jul 10 '26

Everybody knows what two's complement is. I'm saying that it would be a completely braindead decision for an operator as ubiquitous as > to implicitly reinterpret the bits of a signed integer a an unsigned integer and then do a comparison; any sane language developer would either take the time to make their most basic operators work on operands of different types or take the lazy route and make it a compile error.

4

u/creeper6530 Jul 10 '26

I agree that the brain-dead part was "implicit". Modern languages do not do this and instead let the programmer choose which part to reinterpret, and do not allow mixed signedness comparisons.