1. Bit Shift Left and Bit Shift Right
- Posted by "Lucius L. Hilley III" <lhilley at CDC.NET> Feb 18, 2000
- 580 views
In the early days of Euphoria I was complaining about Bit shifting as much as you are now. Euphoria now optimizes some math computations into bit shifting... integer i i = rand(324)-- just some random number i *= 2 -- Shift Left i *= 4 -- Shift left twice. i = floor(i/2) -- Shift right i = floor(i/4) -- Shift right twice? PS: if that doesn't actually become a Shift right it is still computationally equivalent. Don't sweat it. Euphoria is pretty fast for an interpreted language. Lucius L. Hilley III lhilley at cdc.net +----------+--------------+--------------+ | Hollow | ICQ: 9638898 | AIM: LLHIII | | Horse +--------------+--------------+ | Software | http://www.cdc.net/~lhilley | +----------+-----------------------------+
2. Re: Bit Shift Left and Bit Shift Right
- Posted by Joel Crook <joel at MAIL.K-A.COM> Feb 17, 2000
- 619 views
- Last edited Feb 18, 2000
--=====================_520899497==_.ALT I coded some shift functions that are little more formal: -- Euphoric Shift Registers -- -- t is the value to be shifted -- b is the range (number of bits) of the shift -- this can replace a C entry of : x=(a>>10) --with -- x=shift_right(a,10) -- function shift_left(atom t,atom b) atom sl sl=t*power(2,b) return sl end function function shift_right(atom t,atom b) atom sr sr=t/power(2,b) return sr end function It also turns out I was incorrect in stating the need for *32* logical operators --- it seems that 64 bit logical operators are required. At 12:12 AM 02/18/2000 -0500, you wrote: > In the early days of Euphoria I was complaining about Bit shifting as >much as you are now. Euphoria now optimizes some math computations >into bit shifting... > >integer i >i = rand(324)-- just some random number >i *= 2 -- Shift Left >i *= 4 -- Shift left twice. >i = floor(i/2) -- Shift right >i = floor(i/4) -- Shift right twice? > >PS: if that doesn't actually become a Shift right it is still >computationally equivalent. Don't sweat it. Euphoria is pretty fast >for an interpreted language. > > Lucius L. Hilley III > lhilley at cdc.net >+----------+--------------+--------------+ >| Hollow | ICQ: 9638898 | AIM: LLHIII | >| Horse +--------------+--------------+ >| Software | http://www.cdc.net/~lhilley | >+----------+-----------------------------+ Joel H. Crook Manager, Information Services Certified Novell Administrator Microsoft Certified Professional, OS Specialist Kellogg & Andelson Accountancy Corp. 14724 Ventura Blvd. 2nd Floor Sherman Oaks, CA 91403 (818) 971-5100 --=====================_520899497==_.ALT <html><div>I coded some shift functions that are little more formal:</div> <br> <div>-- Euphoric Shift Registers</div> <div>--</div> <div>-- t is the value to be shifted</div> <div>-- b is the range (number of bits) of the shift</div> <div>-- this can replace a C entry of : x=(a>>10) </div> <div>--with </div> <div>-- x=shift_right(a,10)</div> <div>-- </div> <br> <div>function shift_left(atom t,atom b)</div> <div> atom sl</div> sl</div> <div>end function</div> <br> <div>function shift_right(atom t,atom b)</div> <div> atom sr</div> sr</div> <div>end function</div> <br> <div>It also turns out I was incorrect in stating the need for *32* logical operators --- it seems that 64 bit logical operators are required.</div> <br> <div>At 12:12 AM 02/18/2000 -0500, you wrote:</div> <div>> In the early days of Euphoria I was complaining about Bit shifting as</div> <div>>much as you are now. Euphoria now optimizes some math computations</div> <div>>into bit shifting...</div> <div>></div> <div>>integer i</div> <div>>i = rand(324)-- just some random number</div> <div>>i *= 2 -- Shift Left</div> <div>>i *= 4 -- Shift left twice.</div> <div>>i = floor(i/2) -- Shift right</div> <div>>i = floor(i/4) -- Shift right twice?</div> <div>></div> <div>>PS: if that doesn't actually become a Shift right it is still</div> <div>>computationally equivalent. Don't sweat it. Euphoria is pretty fast</div> <div>>for an interpreted language.</div> <div>></div> <div>> Lucius L. Hilley III</div> lhilley at cdc.net</div> <div>>| Hollow | ICQ: 9638898 | AIM: LLHIII |</div> <div>>| Horse +--------------+--------------+</div> <div>>| Software | <a href="http://www.cdc.net/~lhilley" EUDORA=AUTOURL>http://www.cdc.net/~lhilley</a> |</div> <br> Joel H. Crook<br> <br> Manager, Information Services<br> <font size=1>Certified Novell Administrator<br> Microsoft Certified Professional, OS Specialist<br> <br> </font><b>Kellogg & Andelson Accountancy Corp.<br> </b><font size=1>14724 Ventura Blvd. 2nd Floor<br> Sherman Oaks, CA 91403<br> (818) 971-5100<br> </font></html> --=====================_520899497==_.ALT--