<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged bitwise</title>
<link>https://ask.clojure.org/index.php/tag/bitwise</link>
<description></description>
<item>
<title>Why does bit-shift-left rotate bits instead of discarding bits?</title>
<link>https://ask.clojure.org/index.php/9518/why-does-bit-shift-left-rotate-bits-instead-discarding-bits</link>
<description>&lt;p&gt;&lt;code&gt;(bit-shift-left 0xfffffff0 4)&lt;/code&gt; returns &lt;code&gt;0xffffff0f&lt;/code&gt;, while I expect it to be &lt;code&gt;0xffffff00&lt;/code&gt;. Similarly, &lt;code&gt;(bit-shift-left 0xfffffff0 8)&lt;/code&gt; returns &lt;code&gt;0xfffff0ff&lt;/code&gt;, etc.&lt;/p&gt;
&lt;p&gt; I checked the implementation, and &lt;code&gt;bit-shift-left&lt;/code&gt; casts all its arguments to &lt;code&gt;Long&lt;/code&gt;, then invokes Java's &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; operator, which should discard higher bits instead of rotate them.&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9518/why-does-bit-shift-left-rotate-bits-instead-discarding-bits</guid>
<pubDate>Mon, 03 Aug 2020 05:35:41 +0000</pubDate>
</item>
</channel>
</rss>