3 ms·
Java definately made the best decision here. Sad that we still have to live with unsigned types and the promotion rules.
by p0nce 10y ago
Java definately made the best decision here. Sad that we still have to live with unsigned types and the promotion rules.
- computerphage 10y agoCan you explain why?
- curun1r 10y agoPerhaps they made the right decision with int, short and long, but there's one case where they absolutely made the wrong decision: byte. Having signed bytes is extremely obnoxious. Doing any sort of bit- flipping/shifting requires you to add a ton of "& 0xFF" operations that would be completely unnecessary if byte was unsigned. The main use case for bytes is to represent data, not integers and bytes shouldn't have been treated that way.
- prodigal_erik 10y agoThe right choices are bounds checking or autoboxing. I very rarely want arithmetic modulo n (and when I do, I want to choose n), but never do I ever want signed overflow quietly giving wrong answers.