|
From: | Cheng,Jen-Min |
Subject: | [Help-glpk] bigmulin glblib05.c |
Date: | Mon, 4 Jan 2010 10:41:20 -0800 |
With MS Visual Studio 2008, unsigned int is four bytes and unsigned short is two bytes. If the value of the unsigned int t is greater than maximum unsigned short, how will x[i+j] = (unsigned short)t; be executed? Thanks.
void bigmul(int n, int m, unsigned short x[], unsigned short y[])
{ int i, j;
unsigned int t;
xassert(n >= 1);
xassert(m >= 1);
for (j = 0; j < m; j++) x[j] = 0;
for (i = 0; i < n; i++)
{ if (x[i+m])
{ t = 0;
for (j = 0; j < m; j++)
{ t += (unsigned int)x[i+m] * (unsigned int)y[j] +
(unsigned int)x[i+j];
x[i+j] = (unsigned short)t;
t >>= 16;
}
x[i+m] = (unsigned short)t;
}
}
return;
}
[Prev in Thread] | Current Thread | [Next in Thread] |