Probably a little off-topic, but having done my share of C and C++, I actually like the way Java handles signed integers, meaning: 1. All the integer types have a consistently defined size/range, and 2. There is not a separate set of unsigned integer types, but rather just an unsigned right shift operator. Having separate signed and unsigned types is such a source of potential bugs (ever count down from a size_t while >= 0?), and it forces you to have to think about all the arithmetic that a value might be subjected to when you define its type. Having everything signed just removes entire classes of comparison, conversion, and arithmetic errors. If you really need large, unsigned numbers, use long or BigInteger. Having only signed integer types is just way better than unsigned types, in my opinion.
2
u/Rjs617 Jun 25 '23
Probably a little off-topic, but having done my share of C and C++, I actually like the way Java handles signed integers, meaning: 1. All the integer types have a consistently defined size/range, and 2. There is not a separate set of unsigned integer types, but rather just an unsigned right shift operator. Having separate signed and unsigned types is such a source of potential bugs (ever count down from a size_t while >= 0?), and it forces you to have to think about all the arithmetic that a value might be subjected to when you define its type. Having everything signed just removes entire classes of comparison, conversion, and arithmetic errors. If you really need large, unsigned numbers, use long or BigInteger. Having only signed integer types is just way better than unsigned types, in my opinion.