Clojure

unsigned-bit-shift-right

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Add a clojure equivalent of >>>.

The patch implements a new unsigned-bit-shift-right function that has the semantics of Java long >>>. This differs in particular in the handling of the shift distance which uses the least significant 6 bits of the shift distance (thus always in the range 0-63 inclusive). A Java method Numbers.unsignedShiftRightInt is included but not used by the surfaced function.

Patch: clj-827-unsigned-bit-shift-right-with-tests.patch

Screened by: Alex Miller

Related ticket: Ticket CLJS-514 has been created to track the future work of making ClojureScript's name for this operation the same as the one used in Clojure, after this ticket is completed. David Nolen is agreeable to making this change, even though it would rename an already-defined public function.

Activity

Joe Gallo made changes -
Field Original Value New Value
Attachment 0001-add-unsigned-bit-shift-right.patch [ 10694 ]
Tim McCormack made changes -
Rich Hickey made changes -
Approval Vetted [ 10003 ]
Rich Hickey made changes -
Fix Version/s Release 1.6 [ 10157 ]
Gabriel Horner made changes -
Assignee Gabriel Horner [ cldwalker ]
Gabriel Horner made changes -
Gabriel Horner made changes -
Approval Vetted [ 10003 ] Screened [ 10004 ]
Assignee Gabriel Horner [ cldwalker ]
Alex Miller made changes -
Approval Screened [ 10004 ] Incomplete [ 10006 ]
Andy Fingerhut made changes -
Patch Code [ 10001 ] Code and Test [ 10002 ]
Description Add a clojure equivalent of >>>.

A simple version of this is implemented here (https://github.com/joegallo/clojure/tree/unsigned-bit-shift-right), and just follows the example set by shift-right.

The downside of this implementation is that it treats all integer types as longs, and shifts them accordingly, which yields different results than you would get in java. A previous version of this did not have the same problem, when BitOps was its own thing. I'm not sure if this limitation is acceptable and appropriate, or needs to be worked around (my inclination is the latter).
Add a clojure equivalent of >>>.

A simple version of this is implemented here (https://github.com/joegallo/clojure/tree/unsigned-bit-shift-right), and just follows the example set by shift-right.

The downside of this implementation is that it treats all integer types as longs, and shifts them accordingly, which yields different results than you would get in java. A previous version of this did not have the same problem, when BitOps was its own thing. I'm not sure if this limitation is acceptable and appropriate, or needs to be worked around (my inclination is the latter).

Patch: clj-827-unsigned-bit-shift-right-with-tests.patch

The patch consists of 3 commits, the first of which is identical to the commit in patch 0001-CLJ-827-Add-bit-shift-right-logical.patch dated Jan 16 2012, preserving Tim McCormack's authorship. The 2nd commit changes the name of the new operation to unsigned-bit-shift-right, which Gabriel Horner says in a comment on May 24 2013 that he chose after chatting with Rich. The 3rd commit adds tests for the new unsigned-bit-shift-right, plus one for bit-shift-right that distinguishes the behavior of the two operations.

Ticket CLJS-514 has been created to track the future work of making ClojureScript's name for this operation the same as the one used in Clojure, after this ticket is completed. David Nolen is agreeable to making this change, even though it would rename an already-defined public function.
Alex Miller made changes -
Labels math
Alex Miller made changes -
Approval Incomplete [ 10006 ] Screened [ 10004 ]
Description Add a clojure equivalent of >>>.

A simple version of this is implemented here (https://github.com/joegallo/clojure/tree/unsigned-bit-shift-right), and just follows the example set by shift-right.

The downside of this implementation is that it treats all integer types as longs, and shifts them accordingly, which yields different results than you would get in java. A previous version of this did not have the same problem, when BitOps was its own thing. I'm not sure if this limitation is acceptable and appropriate, or needs to be worked around (my inclination is the latter).

Patch: clj-827-unsigned-bit-shift-right-with-tests.patch

The patch consists of 3 commits, the first of which is identical to the commit in patch 0001-CLJ-827-Add-bit-shift-right-logical.patch dated Jan 16 2012, preserving Tim McCormack's authorship. The 2nd commit changes the name of the new operation to unsigned-bit-shift-right, which Gabriel Horner says in a comment on May 24 2013 that he chose after chatting with Rich. The 3rd commit adds tests for the new unsigned-bit-shift-right, plus one for bit-shift-right that distinguishes the behavior of the two operations.

Ticket CLJS-514 has been created to track the future work of making ClojureScript's name for this operation the same as the one used in Clojure, after this ticket is completed. David Nolen is agreeable to making this change, even though it would rename an already-defined public function.
Add a clojure equivalent of >>>.

The patch implements a new {{unsigned-bit-shift-right}} function that has the semantics of Java long >>>. This differs in particular in the handling of the shift distance which uses the least significant 6 bits of the shift distance (thus always in the range 0-63 inclusive). A Java method {{Numbers.unsignedShiftRightInt}} is included but not used by the surfaced function.

*Patch:* clj-827-unsigned-bit-shift-right-with-tests.patch

*Screened by:* Alex Miller

*Related ticket:* Ticket CLJS-514 has been created to track the future work of making ClojureScript's name for this operation the same as the one used in Clojure, after this ticket is completed. David Nolen is agreeable to making this change, even though it would rename an already-defined public function.
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (11)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: