From: MenTaLguY Date: 2008-01-26T07:15:54+09:00 Subject: Re: Circular shift On Sat, 26 Jan 2008 07:03:12 +0900, "Judson Lester" wrote: > On Jan 25, 2008 1:47 PM, Mental Guy wrote: >> Since you showed interest, though, I'll continue with what I would >> have eventually gotten to: if the register width is a power of two, >> you can do some additional tricks. > > Let's just say I share your love for binary arithmetic. But, hey, I'm > more than happy to play straight man for a good punchline. Yeah, your reply struck me as fairly bit-savvy; I'm mostly just writing for the benefit of any bit-curious folks out there on the list. >> [1] Be careful when porting code to other languages; they may differ >> in their treatment of negative numbers with the modulo operator, and >> in C its behavior is platform-dependent. Ruby's way is the best way >> for modular arithmetic though. > > Yeah, no kidding. C (and many related languages) also fix the width > of numeric types and have built-in (<<<) circular shifts. Then there's also the whole shift-with-sign-extension (or not) thing... -mental