Tuesday, July 22, 2008

Twos Complement Worksheet

I recently was doing some testing on some UTF8 character conversion code and since Java does not have any unsigned byte datatypes, it was quite a pain to get UTF8 expansions recoded as signed bytes for the test. I couldn't find anything online that would take a signed byte and return the decimal value of the same bit-pattern as an unsigned. So I wrote this really hacky Google Docs spreadsheet to help myself. Probably there are 1000 better ways to do it, but this is at least a very explicit implementation that shows exactly how the process works.

0 Comments: