[Coin-discuss] arithmetic exception when using Cbc

Michael Hennebry hennebry at web.cs.ndsu.nodak.edu
Thu Nov 2 16:38:35 EST 2006


On Thu, 2 Nov 2006, Matthew Saltzman wrote:

> On Thu, 2 Nov 2006, Kish Shen wrote:

> > I am getting an arithmetic exception when using Cbc/Clp through OsiClp.
> > The crash happens in CbcModel.cpp, in gcd (line 84 in the copy I am
> > using):
> >
> >  while (remainder) {
> >    remainder = b % a;
> >    b = a;
> >    a = remainder;
> >  }
> >  return b;
> >
> > The crash happens  in doing the % operation, I assume because a = -1.

???
x % -1 == 0
It seems to me that the loop must have been entered with a==0.
Otherwise a==remainder!=0 when the mod is taken.
There is no other place for an arithmetic exception
unless one is using a machine on which some values
cannot be copied or cannot be tested.

> Seems like an arithmetic exception should be easy to find.  Do you know
> what the args are that cause the crash?  What arch is this on?
>
> One thing about / and % in C (resp. C++) is that they are ambiguous.  The
> standard requires that (a/b) * b + a % b = a, but it does not require that
> a % b >= 0, Some architectures return negative remainders if the dividend
> or divisor is negative.
>
> On SPARC, for example, -4 % -6 == -4, -4 % 6 == -4, 4 % -6 == 4.

-- 
Mike   hennebry at web.cs.ndsu.NoDak.edu
"it stands to reason that they weren't always called the ancients."
                                                      --  Daniel Jackson




More information about the Coin-discuss mailing list