Java’s missing unsigned integer types


This is a topic that has been discussed many times before. Java’s lack of unsigned byte/short/int/long types. The main reasons why the JLS designers omitted those types were:

  1. They’re hardly really useful
  2. They’re a bit more difficult to implement
  3. They’re a bit more difficult to understand
  4. They would lead to more primitive types that have to be treated separately from the existing ones
  5. … and probably, there are more reasons

Nevertheless, these types are sometimes useful for cryptography, image processing, binary protocols, everything related to binary data (why is byte unsigned after all??), and the list of rants in the following ticket at Sun/Oracle is long:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504839

For jOOQ, unsigned number types would be useful, as some databases support them (e.g. MySQL, Postgres). And they’re not necessarily trivial to map to Java. So I was looking for a good solution. The best one being to use wrapper classes extending java.lang.Number. So, I have raised the question on Stack Overflow to find such a library:

http://stackoverflow.com/questions/8193031/is-there-a-java-library-for-unsigned-number-type-wrappers

Incredibly, no one seems to have done this – except for some partial implementations in some large libraries. So I’m launching a new OSS project called jOOU – U is for Unsigned. Check out a small library for Java Unsigned Number wrappers:

http://code.google.com/p/joou/

Tags: , , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,745 other followers

%d bloggers like this: