tag:blogger.com,1999:blog-6204005997345471829.post1891901284704134774..comments2023-03-25T11:24:24.318+00:00Comments on Bad Concurrency: Arithmetic Overflow and IntrinsicsMichael Barkerhttp://www.blogger.com/profile/16232688819921959379noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-6204005997345471829.post-42602413911971919652013-07-18T10:53:28.830+01:002013-07-18T10:53:28.830+01:00Oops! I missed the mask. Thanks for the article.Oops! I missed the mask. Thanks for the article.Anonymoushttps://www.blogger.com/profile/15213081379539137775noreply@blogger.comtag:blogger.com,1999:blog-6204005997345471829.post-86914808388704224622013-07-17T22:05:45.207+01:002013-07-17T22:05:45.207+01:00Hi Rajiv,
There's no Byte.bitCount that I'...Hi Rajiv,<br /><br />There's no Byte.bitCount that I'm aware of. You'll be stuck with:<br /><br />Integer.bitCount(0xFF & b)<br /><br />For the time being. Don't forget the mask otherwise negative values will give incorrect results.<br /><br />As to the performance you'd have to measure it yourself. Probably worth looking at the generated assembler too.Michael Barkerhttps://www.blogger.com/profile/16232688819921959379noreply@blogger.comtag:blogger.com,1999:blog-6204005997345471829.post-38606131498317908992013-07-17T12:07:15.105+01:002013-07-17T12:07:15.105+01:00Is there an equivalent intrinsic for getting the n...Is there an equivalent intrinsic for getting the number of set bits on a Java Byte?<br /><br />I can always do Integer.bitCount(someByte) since byte to Int is not a downcast. Is this cast an expensive operation. <br /><br />What I am really looking for is a Java equivalent for __builtin_popcount(some_uint8_t)Anonymoushttps://www.blogger.com/profile/15213081379539137775noreply@blogger.comtag:blogger.com,1999:blog-6204005997345471829.post-12741206901051878802012-08-30T14:09:08.971+01:002012-08-30T14:09:08.971+01:00Superb article Mike!
I completely agree that the...Superb article Mike! <br /><br />I completely agree that these features should be added as utilities rather than adding complexity to the basic language - especially as this must only be a requirement for a tiny percentage of Java users.robannhttps://www.blogger.com/profile/00928193244559930423noreply@blogger.com