title: Does the return type save space or time
body: <p>Does the return type matter when returning from a function?</p>
  
  <p>This is kind of a 2-part question.
  I believe an 8-bit operation would be the same as a 32-bit operation.
  I believe an 8-bit value is operated on in a 32-bit register, so it will be promoted to a 32-bit value. Then it would be casted back down to an 8-bit value.</p>
  
  <pre><code>unsigned char SomeFunc()   &lt;- Quickest and less memory.
  unsigned short SomeFunc()
  unsigned long SomeFunc()
  </code></pre>
  
  <p>"All operations should be performed on the smallest variable wherever possible, this saves both time and space" True or False?</p>
  
  <p>On a 32 bit operating system, I don't believe it would matter, since the return register is 32 bits anyways, whether it be a variable or an address.
  So it would neither save time, nor space.</p>
  
  <p>I do understand that there might be a need to return a char/byte, if that's all your dealing with, but you could still return a long and cast it.
  I think your still casting either way whether before or after you leave the function. I almost think it is easier and faster to deal with 32 bit values than 16 or 8 bit values.</p>
  
  <p>Second part.
  In the following function, I don't believe it would make it any quicker or save any more space if I were to return a unsigned short instead.</p>
  
  <pre><code>unsigned long SomeFunc(unsigned char a, unsigned char b);
  {
    unsigned long c = a + b;
    return c;
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>unsigned long SomeFunc(unsigned char a);
  {
    //This will be promoted to a 32-bit value anyways.
    return a &amp; 0x1;
  }
  </code></pre>
  
  <p>The following function would somehow be quicker and take up less memory?</p>
  
  <pre><code>unsigned char SomeFunc(unsigned char a);
  {
    //This will be promoted to a 32-bit value anyways.
    return a &amp; 0x1;
  }
  </code></pre>