title: How to multiply 32-bit integers in c
body: <p>Execution of:  </p>
  
  <pre><code>#define HIGH32(V64) ((uint32_t)((V64 &gt;&gt; 32)&amp;0xffFFffFF))
  #define LOW32(V64) ((uint32_t)(V64&amp;0xffFFffFF))
  
  uint32_t a = 0xffFFffFF;
  uint32_t b = 0xffFFffFF;
  uint64_t res = a * b;
  printf("res = %08X %08X\n", HIGH32(res), LOW32(res));
  </code></pre>
  
  <p>Gives: </p>
  
  <pre><code>"res = 00000000 00000001"
  </code></pre>
  
  <p>But I expect: fffffffe00000001. What did I do wrong? Single assignment:</p>
  
  <pre><code>res = 0x0123456789ABCDEF;
  printf("res = %08X %08X\n", HIGH32(res), LOW32(res));
  </code></pre>
  
  <p>Gives</p>
  
  <pre><code>res = 01234567 89ABCDEF
  </code></pre>
  
  <p>Environment:</p>
  
  <pre><code>$gcc --version
  gcc (GCC) 4.8.3
  Copyright (C) 2013 Free Software Foundation, Inc.
  
  $ gcc -v
  COLLECT_GCC=gcc
  COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.8.3/lto-wrapper.exe
  dest arch: i686-pc-cygwin
  
  $ file a.exe
  a.exe: PE32 executable (console) Intel 80386, for MS Windows
  </code></pre>