help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] bigmul in glblib05.c


From: Michael Hennebry
Subject: Re: [Help-glpk] bigmul in glblib05.c
Date: Wed, 6 Jan 2010 10:32:55 -0600 (CST)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Wed, 6 Jan 2010, Andrew Makhorin wrote:

These codes are replaced with

unsigned short c = (unsigned short)( i & USHRT_MAX);

The modified codes can produce 13.75 for vpm2.mps of MIPLIB 2003.

I am not sure why you are changing the code. Doesn't the original
version work for you? The glpk code is highly portable, and there is
no need to "improve" its portability in such way.

The statement:

  unsigned short c = (unsigned short)( i & USHRT_MAX);

is absolutely equivalent to:

  unsigned short c = (unsigned short)i;

Actually it's not.
The result of the latter statement can be determined
from the value of i and the value of USHRT_MAX.
If i is negative, the result of the former also
depends on the representation of negative numbers.
I'd go with the latter.
Failing that, I'd put in a test for twos complement:
unsigned short c = (unsigned short)( (i & USHRT_MAX) + (1-1/(-1==1+~1)));

--
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."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]