   [java] Why can't JAVA do unsigned types?
  I just discovered this yesterday. Why did anyone write a programming language that cant do this. Is there any way to implement something similar? Specifically unsigned bytes. 
  I''ve never felt that I needed unsigned variables, but maybe that''s just me. Don''t think there is a way to do it though... ;  you can AND the byte value with 0xff to get the unsigned byte...byte b = -1;int  val = b & 0xff;  the val will be 255.;  If you're really desperate you could use a char.  They are 16bit unsigned integers (in java).   [edited by - arm on January 21, 2004 11:44:51 AM];  How could anyone be cruel enough to design Java in the first place? ;  I think I have to agree with AP. I need it for a compression techinque, I worked out the anding thing already, but thanks for the replies.garazdawi: I think that you''ll find in things like compression and image prosessing are made easier with unsigned bytes. ;  Though I agree that unsigned types can be useful, I fail to see what it would change in the case of compression and image processing. Could you be more specific please ? (no irony nor flames here, real interest)As of myself, the only case where I explicitly needed an unsigned type was when I add to implement stuff related to a specification (I had therefore no control on the chosen data type). But IMHO this specification was badly designed to begin with : who really needs windows that can be 2^32 units large ? ;quote:Original post by pkelly83  garazdawi: I think that you''ll find in things like compression and image prosessing are made easier with unsigned bytes. aa, that explains why I never have found it useful. I haven''t done any compression at all as I''m still in my cradle (so to speak)...;  I would rather have unsigned operators than unsigned types. This will decrease overuse of unsigned types. I found usability of unsigned types in this  i=something;e=array;<br>if i could be unsigned then low bound checking could be disabled by default. <br>signed and unsigned in data compression isn't as important. You'd do just a &#111;ne more instruction. <br>i=&lt;&lt;c;<br>i=&mask63;<br><br>As for images. You use 32 bit integers anyway, so you could add alfa chanel from separate array. It's easier like this anyway. <br><br>I remmember programming language without and operations (applicable &#111;n integers). That was severaly bigger problem than lack of MUL in Java. <br><br> <br> <br><br><SPAN CLASS=editedby>[edited by - raghar on January 23, 2004 1:28:25 PM]</SPAN>;quote:Original post by overnhet  Though I agree that unsigned types can be useful, I fail to see what it would change in the case of compression and image processing. Could you be more specific please ? (no irony nor flames here, real interest)Some image formats store the RGB data as 3 or 4 separate bitplanes, it''s easier to load these into unsigned bytes. Usigned bytes are useful in writing Emulators of older hardware or microprocessors. Usigned types save memory as well.What I was trying to do was compress  two values of 0 to 15 in an unsigned byte. That is to store the value 2 and then 10, the byte would be 0xA2 (Java is big-endian). This was to save memory because I''m writing for mobile devices. I have an unsigned byte in JAVA working now anyway.The argument over whether unsigned types are useful or not could probably turn into a OpenGL vs DirectX or C++ vs JAVA type of thing. IMO unsigned types are useful, others may not use them  and I have no problem with this, but they aren''t going to stop me using unsigned types by flaming the thread!