title: Cant solve "warning: conversion to 'long unsigned int' from 'int'"
body: <p>When I compile <a href="http://www.math.sci.hiroshima-u.ac.jp/%7Em-mat/MT/MT2002/CODES/mt19937ar.c" rel="nofollow noreferrer">mt19937ar.c</a>, a pretty standard random number generator, I keep getting issues with a bit of code that I need from it.</p>
  <blockquote>
  <p>In function 'init_genrand':</p>
  <p>warning: conversion to 'long unsigned int' from 'int' may change the sign of the result</p>
  </blockquote>
  <pre><code>/* Period parameters */  
  #define N 624
  #define M 397
  #define MATRIX_A 0x9908b0dfUL   /* constant vector a */
  #define UPPER_MASK 0x80000000UL /* most significant w-r bits */
  #define LOWER_MASK 0x7fffffffUL /* least significant r bits */
  
  static unsigned long mt[N]; /* the array for the state vector  */
  static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
  
  /* initializes mt[N] with a seed */
  void init_genrand(unsigned long s)
  {
      mt[0]= s &amp; 0xffffffffUL;
      for (mti=1; mti&lt;N; mti++) {
          mt[mti] = 
              (1812433253UL * (mt[mti-1] ^ (mt[mti-1] &gt;&gt; 30)) + mti); 
          /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
          /* In the previous versions, MSBs of the seed affect   */
          /* only MSBs of the array mt[].                        */
          /* 2002/01/09 modified by Makoto Matsumoto             */
          mt[mti] &amp;= 0xffffffffUL;
          /* for &gt;32 bit machines */
      }
  }
  </code></pre>
  <p>Specifically, the error is with</p>
  <pre><code>mt[mti] = 
              (1812433253UL * (mt[mti-1] ^ (mt[mti-1] &gt;&gt; 30)) + mti);
  </code></pre>
  <p>I've tried casting it via</p>
  <pre><code>mt[mti] = (long unsigned int)
              (1812433253UL * (mt[mti-1] ^ (mt[mti-1] &gt;&gt; 30)) + mti); 
  </code></pre>
  <p>which really doesn't make sense to do but I'm just attempting something. This code is from 1997- figured someone would have caught this by now and fixed it. How can I solve this? Or get my compiler to stop crying about it?</p>