tag:blogger.com,1999:blog-7963198204855313475.post346354283290376415..comments2018-05-22T21:39:23.507-06:00Comments on bits of SoftWx: Deterministic Miller-Rabin Primality Test in C#Steve Hatchetthttp://www.blogger.com/profile/00424027621936625044noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7963198204855313475.post-42615075102488035042014-05-04T00:07:03.103-06:002014-05-04T00:07:03.103-06:00Your are correct that mod (%), multiplication and ...Your are correct that mod (%), multiplication and division of literals that are powers of 2 are optimized in release builds, so there is no advantage to using the bit fiddling equivalents. I know better than to bother, but old habits die hard. I agree that it's clearer to just use the normal operators.Steve Hatchetthttps://www.blogger.com/profile/00424027621936625044noreply@blogger.comtag:blogger.com,1999:blog-7963198204855313475.post-70956143223891607942014-04-28T06:41:00.059-06:002014-04-28T06:41:00.059-06:00Nice idea alternating 2 and 4 in the naive prime t...Nice idea alternating 2 and 4 in the naive prime testing. I extended the idea to the primes 2, 3, 5 and 7. I should be about 1/3 faster.<br /><br />http://pastebin.com/NRvepd5S<br /><br />I generated the loop body by a simple program. It could be extended to 11 or even 13, but I didn't bother to test if it's worth it.<br /><br />By the way I'm not a fan of using &1 instead of %2. It shouldn't increase the effectiveness at all (it would take an especially dump optimizer to use division instead of &1). I see you using /2 instead of >>1 (the optimizer should take care of that too).Anonymousnoreply@blogger.com