Re: Bit-Shift without Sign-Extend?

2009-05-23 Thread CuppoJava
That's a very elegant way of expressing it. Thanks for that tip Kevin. -Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsub

Re: Bit-Shift without Sign-Extend?

2009-05-23 Thread ke...@ksvanhorn.com
Here's how I implemented the ">>>" operator for ints: (let [intmask (dec (bit-shift-left 1 32))] (defmacro ushr [x n] `(int (bit-shift-right (bit-and ~intmask ~x) ~n The (bit-and intmask x) expression effectively gives you the unsigned equivalent of x. For bytes, use 255 instead of intmas

Re: Bit-Shift without Sign-Extend?

2009-05-22 Thread Vincent Foley
Like other mentioned in the thread, Java has neither the >>> operator, nor unsigned data types. With that said, I think the function you are looking for is bit-shift- right: user> (bit-shift-right 2r1110 1) 7 I hope this helps. Vincent. On May 21, 9:39 pm, CuppoJava wrote: > Hi everyone, > I

Re: Bit-Shift without Sign-Extend?

2009-05-22 Thread Michael Wood
On Fri, May 22, 2009 at 5:17 PM, CuppoJava wrote: > > Wow that's news to me... > I thought this was a fairly standard operator. I'm surprised that Java > doesn't have a correct version of it. I think the problem is that Java does not have unsigned bytes (or other integer types). e.g. see here:

Re: Bit-Shift without Sign-Extend?

2009-05-22 Thread CuppoJava
Wow that's news to me... I thought this was a fairly standard operator. I'm surprised that Java doesn't have a correct version of it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gr

Re: Bit-Shift without Sign-Extend?

2009-05-22 Thread David Powell
On Fri 22/05/09 03:39 , "CuppoJava" patrickli_2...@hotmail.com sent: > > Hi everyone, > I'm just wondering where the equivalent of the ">>>" > operator is forClojure. I need it to do a divide-by-power-of-2 on unsigned > bytes. Java doesn't have this either. Its >>> operator doesn't work prop

Re: Bit-Shift without Sign-Extend?

2009-05-21 Thread Daniel Lyons
On May 21, 2009, at 7:39 PM, CuppoJava wrote: > > Hi everyone, > I'm just wondering where the equivalent of the ">>>" operator is for > Clojure. I need it to do a divide-by-power-of-2 on unsigned bytes. I could use this too. — Daniel Lyons http://www.storytotell.org -- Tell It! --~--~---

Bit-Shift without Sign-Extend?

2009-05-21 Thread CuppoJava
Hi everyone, I'm just wondering where the equivalent of the ">>>" operator is for Clojure. I need it to do a divide-by-power-of-2 on unsigned bytes. -Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure"