To turn a signed byte (-128 to 127) into an unsigned one:

(bit-and the-byte 0xff)

The byte (for example 0x80, which is negative) will be extended to an
int (0xffffff80) and anded with 0x000000ff (and you get 0x00000080,
which is positive).

The javadoc for the methods of DataInput[1] contain formulas for how
to convert shorts and ints and longs too. DataOutput[2] contains
comments for the opposite opereration.

1. http://download.oracle.com/javase/6/docs/api/java/io/DataInput.html
2. http://download.oracle.com/javase/6/docs/api/java/io/DataOutput.html

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to