title: hex input to bitset<64> C++
body: <p>Can anyone explain why the following does not work for me please?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;bitset&gt;
  
  using namespace std;
  
  int main()
  {
  string tempString;
  uint64_t tempValue;
  
  cout &lt;&lt; "enter addr in hex : ";
  cin &gt;&gt; tempString;
  istringstream ost(tempString);
  ost &gt;&gt; hex &gt;&gt; tempValue;
  bitset&lt;64&gt;  addr(tempValue);
  cout &lt;&lt; "addr = " &lt;&lt; addr &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Only the lowest 32 bits of the bitset are set correctly.  The highest bits remain 0.  I have tried also using unsigned long long in place of uint64_t.</p>
  
  <p>I am using windows vista and the code::blocks editor which was only recently installed.</p>
  
  <p>I have tried installing code::blocks onto another machine I have running windows xp and the problem is the same.</p>
  
  <p>edit 2 --</p>
  
  <p>I changed the code to the following</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;bitset&gt;
  
  using namespace std;
  
  int main()
  {
  string tempString;
  uint64_t tempValue;
  
  cout &lt;&lt; "enter addr in hex : ";
  cin &gt;&gt; tempString;
  istringstream ost(tempString);
  if (ost &gt;&gt; hex &gt;&gt; tempValue) cout &lt;&lt; "ok" &lt;&lt; endl; else cout &lt;&lt; "bad" &lt;&lt; endl;
  ost &gt;&gt; hex &gt;&gt; tempValue;
  cout &lt;&lt; tempValue &lt;&lt; endl;
  bitset&lt;64&gt;  addr(tempValue);
  cout &lt;&lt; "addr = " &lt;&lt; addr &lt;&lt; endl;
  }
  </code></pre>
  
  <p>and now when I input <code>ffffffffff</code> i get the output </p>
  
  <pre><code>ok
  1099511627775
  addr = 0000000000000000000000000000000011111111111111111111111111111111
  </code></pre>
  
  <p>Thanks.</p>