4 ms·
I would go further in that many programmers don't understand the difference between logical and arithmetic operations and why they exist. I have had to puzzle
by bsder 7y ago
I would go further in that many programmers don't understand the difference between logical and arithmetic operations and why they exist.
I have had to puzzle over far too much code doing adds/subtracts/multiplies/divides instead of and/or/xor/shift FAR too often.
I blame Java not having an unsigned type. There are apparently some weird tricks you can do with arithmetic in Java that operate on things like an unsigned type without having to go up to the next higher integer width.
- vbezhenar 7y agoWhat exactly do you miss in Java? It's possible to treat int as unsigned for all the necessary operations.
- blibble 7y agoplus Java's had various unsigned integer operations on Integer for years
- pjmlp 7y agoBlame it on developers that think they know unsigned math. > One of the little experiments I tried was asking people about the rules for unsigned arithmetic in C. It turns out nobody understands how unsigned arithmetic in C works. There are a few obvious things that people understand, but many people don't understand it. https://www.artima.com/intv/gosling3.html https://www.artima.com/intv/gosling3.html Since 2014 that Java now has support for unsigned math via methods on its boxed types since Java 8. And depending on how Valhalla goes, it might gain inline classes for unsigned types, which is pretty much the same thing as having an uint.