Note that there are some explanatory texts on larger screens.

plurals
  1. PODifference in integer size for 64-bit system(confuse with my old 32-bit pc system)
    primarykey
    data
    text
    <p>Few months ago i get myself a laptop with cpu intel i7-2630qm with a 64-bit windows. While practising my programming skils under this system , I encountered some difference in terms of integer size which makes me think that it's probably due to my new 64-bit system.</p> <p>Let's take a look at a code.</p> <p><b>The C Code :</b></p> <pre><code>#include &lt;stdio.h&gt; int main(void) { int num = 20; printf("%d %lld\n" , num , num); return 0; } </code></pre> <p><b>The Question :</b></p> <p>1.) I remember before getting this new laptop , which mean that time i'm still using my old 32-bit system , when i run this code , the program will print the integer <code>20</code> while some random number next to it due to the <code>%lld</code> specifier.</p> <p>2.)But this phenomena no longer happen when i'm using my new laptop , it will instead print both integer correctly , even if i change the variable <code>num</code> to type <code>short</code>.</p> <p>3.)Is it on a 64-bit system , there's new integer promotion which will promote <code>int</code> to long long when it's use as an argument??Or is it <code>short</code> integer can be promoted to <code>long long</code> which is 64-bit too when pass as an argument??</p> <p>4.)Besides that I'm quite confuse with one thing , on 16-bit system , <code>int</code> would be 16-bit and it would be 32-bit when it's on a 32-bit system.But why isn't it become 64-bit when it's on a 64-bit??</p> <p>================================================================================== <b>Addon :</b></p> <p>1.)I choose "console program(64-bit)" as my project on the IDE while using my new laptop but "console program" on my 32-bit old PC system.</p> <p>2.)I've check the size of <code>int</code> under "console program(64-bit)" project using <code>sizeof</code> operator and it returns 32-bit while <code>short</code> still remain 16-bit.The only change is <code>long</code> type , it's 64-bit and <code>long long</code> still remain its usual 64-bit size.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload