Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 26 |
Nodes: | 6 (0 / 6) |
Uptime: | 56:10:40 |
Calls: | 632 |
Files: | 1,187 |
D/L today: |
27 files (19,977K bytes) |
Messages: | 179,568 |
I was trying to wrap my head the >>> operator
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift
The unsigned right shift (>>>) operator returns a number whose
binary representation is the first operand shifted by the
specified number of bits to the right. Excess bits shifted off
to the right are discarded, and zero bits are shifted in from
the left. This operation is also called "zero-filling right
shift", because the sign bit becomes 0, so the resulting number
is always positive.
This is what I understood but it looks too complicated
PS. Anyone know what happened to PJB, his online presence seems to have
been discontinues.
https://stackoverflow.com/questions/1691292/how-to-do-bit-wise-zero-filling-right-shift-in-scheme--
https://stackoverflow.com/questions/26151644/why-is-there-no-unsigned-left-shift-operator-in-java
Aidan Kehoe <kehoea@parhasard.net> writes:
Ar an c||igi|| l|i d|-ag de m|! Deireadh F||mhair, scr|!obh Madhu:
Something like:
(defun fixed-width-ash (width value count)
(ash (logand value (lognot (ash -1 width))) count))
Construct an integer of the desired width that is all 1s, logand it
with VALUE, then shift by COUNT.
Your compiler will probably recognize that this is equivalent to:
(defun fixed-width-ash (width value count)
(ash (logandc2 value (ash -1 width)) count))
But I would write it that way in the first place because I like to
remember that the PDP-10 had an ANDCM instruction...