[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## FW: [Help-glpk] bigmulin glblib05.c

**From**: |
Cheng,Jen-Min |

**Subject**: |
FW: [Help-glpk] bigmulin glblib05.c |

**Date**: |
Tue, 5 Jan 2010 05:31:11 -0800 |

Because MSVS 2008 would issue warning for such a conversion, the bigmul
is modified as
void bigmul(int n, int m, unsigned short x[], unsigned short y[])
{
int i, j;
unsigned int t;
union {
unsigned int uint;
struct { unsigned short ush1, ush2 ;} ush;
} tuiush;
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];
tuiush.uint = t;
x[i+j] = (unsigned short)tuiush.ush.ush1;
// 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;
}
Similar modification is applied to xldiv in glplib06.c.
The modified code can converge to the solution 13.75 of vpm2.mps of
MIPLIB2003.
Andrew and Michael : Thanks your explanation.
-----Original Message-----
From: Michael Hennebry [mailto:address@hidden
Sent: Monday, January 04, 2010 1:41 PM
To: Cheng,Jen-Min
Cc: address@hidden
Subject: Re: [Help-glpk] bigmulin glblib05.c
On Mon, 4 Jan 2010, Cheng,Jen-Min wrote:
>* 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.*
The manner C prescribes is x[i+j]= t mod 2**16,
assuming two bytes mans 16 bits.
--
Michael address@hidden
"Pessimist: The glass is half empty.
Optimist: The glass is half full.
Engineer: The glass is twice as big as it needs to be."