title: cast double into short
body: <p>I have an application where i HAVE to store <code>unsigned short</code> data in a <code>double</code> parallel vector to be able to easily move it around. Whenever I actually need the data, I cast them back to <code>unsigned short</code>. I know my data, although saved in a <code>double</code> vector, are well within the range of <code>unsigned short</code> i.e. the values stored are all between <code>0</code> and <code>2^16-1</code>.</p>
  
  <p>Question is, since <code>sizeof(double) = 8</code> and <code>sizeof(unsigned short) = 2</code> could this cause data loss when casting? I know one problem is if the data is changed by a small bit when in <code>double</code> form, it might be rounded to another number but that is not my concern right now.</p>
  
  <p>thanks</p>