How do I get unsigned ints in Java?
[*] Java doesn’t have unsigned ints. The reason is that this is a poorly designed area of C. The rules for what type you end up with when you mix signed and unsigned in expressions are complicated, and they changed between K&R and ANSI C (you might have heard this under the name “unsigned preserving vs. value preserving”). Worse, they depended on the underlying hardware, so they varied from platform to platform, causing bugs in all kinds of unexpected places. The book “Expert C Programming” goes into this in more depth (page 25). So, to avoid bringing over the hidden complexities, Java does not bring over unsigned types from C. Use type char if you are OK with 16-bit unsigned quantities. Otherwise, go to the next larger type and use masking. If you don’t have to worry about division by numbers with the high bit set, then when you use >>> for right shift and remember to AND each byte with 0xFF where they are being expanded into a larger type, then there is no difference in the bit patte