Welcome! Please see the About page for a little more info on how this works.

0 votes
in Java Interop by

(bit-shift-left 0xfffffff0 4) returns 0xffffff0f, while I expect it to be 0xffffff00. Similarly, (bit-shift-left 0xfffffff0 8) returns 0xfffff0ff, etc.

I checked the implementation, and bit-shift-left casts all its arguments to Long, then invokes Java's << operator, which should discard higher bits instead of rotate them.

1 Answer

+2 votes
by
selected by
 
Best answer

Maybe something went wrong between bit-shift-left and the output. Does this look right?

user> (format "%x" (bit-shift-left 0xfffffff0 4))
"fffffff00"
by
All right, I used "%h" as the format string thinking "h" means "hex". Turns out "%h" calls hashCode() in Java to convert a value into hex. That was silly.
...