Welcome to my site!Stories by T. Gene DavisPoetry by T. Gene DavisMagazine of fiction and poetry by T. Gene DavisAbout T. Gene Davis

com.genedavis.util.GDBytes

This class is for the converting of unsigned bytes, represented by ints to signed bytes or going the other direction, signed to unsigned.

Java lives up to the Perl mantra of making simple things easy and hard things possible. One example is network protocol implementation. If you've implemented one in java, you've probably dealt with the small number of primative types that Java offers over c or c++. Normally this is a plus, IMHO, but not when doing low level work. Signed byte to unsigned byte conversions, or visa-versa, are the most used low level trick you'll need.

You can use these two static methods to do the conversion, or just look at the source and copy the code. It's not much code, just not well documented in most Java textbooks that I've seen.


GDBytes.class
GDBytes.java