On Fri, Feb 11, 2011 at 12:22 PM, timc <timgcl...@gmail.com> wrote: > How on earth is one supposed to do communication programming (not to > mention handling binary files etc) without an unsigned byte type? > > I see that this issue has been talked about vaguely - is there a > solution? > > Thanks > > Java guarantees twos complement representations for integers- and in twos complement, the only operations which are different between signed and unsigned are shift right, divide, and modulo. Java provides a >>> operator for doing an unsigned shift right- not sure how to access it from clojure, I haven't needed to do that yet. For div and mod you need to up the data size (convert ints to longs, or longs to bigints) and do them there.
By the way, a nice way to think about 2's complement arithmetic is the following: it stores -x as the unsigned number 2^32 - x (or 2^64 - x for 64-bit longs), and then does everything as unsigned arithmetic modulo 2^32 (or 2^64). Brian -- 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