{"id":759,"date":"2006-08-30T07:52:05","date_gmt":"2006-08-30T15:52:05","guid":{"rendered":"http:\/\/arcanius.silverfir.net\/wp\/javas-lack-of-unsigned-types-considered-harmful"},"modified":"2006-08-30T07:52:05","modified_gmt":"2006-08-30T15:52:05","slug":"javas-lack-of-unsigned-types-considered-harmful","status":"publish","type":"post","link":"https:\/\/arcanius.silverfir.net\/blog\/javas-lack-of-unsigned-types-considered-harmful\/","title":{"rendered":"Java&#8217;s Lack of Unsigned Types Considered Harmful"},"content":{"rendered":"<p>I have been aware of Java&#8217;s lack of unsigned types for a long time, but it was never really an issue for me &#8212; until today that is. Enter arrays of bytes, which Java considers signed and only signed and nothing but signed. The only way around it is a massively ugly hack that goes soemthing like this:<\/p>\n<p><code>buf[i] & 0x000000FF<\/code><\/p>\n<p>This promotes to an int, then chops off the signed stuff, and gives you a signed int that is big enough to hold all the values that an unsigned byte might. <\/p>\n<p>I found an excellent delving into the <a href=\"http:\/\/www.darksleep.com\/player\/JavaAndUnsignedTypes.html\">reasons for this nonsense<\/a>; it ends on this sad but all-to-true remark:<\/p>\n<blockquote><p>In the sidebar it says: &#8220;unsigned isn&#8217;t implemented yet; it might never be.&#8221; How right you were.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I have been aware of Java&#8217;s lack of unsigned types for a long time, but it was never really an issue for me &#8212; until today that is. Enter arrays of bytes, which Java considers signed and only signed and nothing but signed. The only way around it is a massively ugly hack that goes [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-759","post","type-post","status-publish","format-standard","hentry","category-everything"],"_links":{"self":[{"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/posts\/759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/comments?post=759"}],"version-history":[{"count":0,"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/posts\/759\/revisions"}],"wp:attachment":[{"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/media?parent=759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/categories?post=759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arcanius.silverfir.net\/blog\/wp-json\/wp\/v2\/tags?post=759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}