bug-glpk
[Top][All Lists]
Advanced

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

[Bug-glpk] Minor problem in mps_numb


From: Vlahos, Kiriakos
Subject: [Bug-glpk] Minor problem in mps_numb
Date: Wed, 28 Aug 2002 21:02:36 +0100

First of all thanks very much for your work on GLPK which is shaping up to
become the very best open source optimizer and competitive with  the
commercial ones.

Much appreciated.

This is to report one minor issue with the routine mps_numb in glplpx8.c
(versions 3.2 and 3.2.1).

static char *mps_numb(double val, char numb[12+1])
{     int n;
      char str[255+1], *e;
      for (n = 12; n >= 6; n--)
      {  if (val != 0.0 && fabs(val) < 0.002)
            sprintf(str, "%.*E", n, val);
         else
            sprintf(str, "%.*G", n, val);
         insist(strlen(str) <= 255);
         e = strchr(str, 'E');
         if (e != NULL) sprintf(e+1, "%d", atoi(e+1));
         if (strlen(str) <= 12) return strcpy(numb, str);
      }
      fault("lpx_write_mps: can't convert floating point number '%g' to"
         " character string", val);
      return NULL; /* to relax the compiler */
}

The routine above creates a fault when called with a parameter val which is
a negative number and gets fornatted with a negative two digit exponent.
(i.e -0.2141234123E-10).    I recognize that this is a rather rare condition
but it the fault can be prevented simply by changing the 6 to 5 in the
following line.

      for (n = 12; n >= 6; n--)

Regards

Kiriakos Vlahos








reply via email to

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