[Coin-discuss] Problem with MPS export / MSVC

Jörg Herbers herbers at hotmail.com
Fri Apr 2 03:06:41 EST 2004


John,

thanks for the solution - this works perfectly now!

Jörg



>>>jjforre at us.ibm.com 4/1/2004 9:49:52 PM >>>
Jörg,

With formatType 1 CoinMpsIO::writeMps() writes 18 digits of accuracy (well
it does now).

I have modified code to take out leading zeros in exponent.  That should
work as numbers > 1.0e40 are treated differently with formaType 0 so there
will always be at least one 0 on Microsoft.

John Forrest



"Jörg Herbers" <herbers at hotmail.com>
Sent by: coin-discuss-admin at www-124.southbury.usf.ibm.com
03/25/2004 10:11 AM
Please respond to
coin-discuss


To
coin-discuss at www-124.southbury.usf.ibm.com
cc

Subject
[Coin-discuss] Problem with MPS export / MSVC






I encountered a problem when exporting an mps file via CoinMpsIO. I work
on
Microsoft Visual Studio .NET 2003 which handles printf format
specification
flags somewhat different from e.g. the gcc compiler. The problem is that
large "infinity" upper bounds are exported as "2.147484e+00", i.e. the
exponent is 0. CoinMpsIO::writeMps() takes the minimum over the given
upper
bound and INT_MAX (2147483647). convertDouble() converts this to a string,

using format specification "%12.7g". The resulting string is cut after 12
characters according to the MPS specification for the BOUNDS section. But
while gcc converts INT_MAX into 2.147484e+09, MS VC7 (and equally MS VC6)
converts it into 2.147484e+009, and the final "9" at position 12 will be
cut
afterwards. The Microsoft documentation says that the exponent will always

be typeset with three digits while gcc uses two digits for exponents <100.
I
don?t know if the C++ standard defines a "correct" behaviour.

I have solved the problem in my COIN code, but I would clearly prefer a
general solution. Several ways are viable: On the one hand, the format
specifications could generally be changed to "%12.6g". On the other hand,
there could be a specific solution for the Microsoft compiler, e.g. by the

above reduction of significant digits or by a manipulation of the
resulting
string, e.g. by something like

#if defined(_MSC_VER)
    if ((outputValue[9] == '+') && (outputValue[10] == '0'))
      strcpy(&(outputValue[10]), &(outputValue[11]));
#endif

I would be very glad if you could integrate a fix into the code.

Thanks a lot,
Jörg

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

_______________________________________________
Coin-discuss mailing list
Coin-discuss at www-124.ibm.com
http://www-124.ibm.com/developerworks/oss/mailman/listinfo/coin-discuss

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus




More information about the Coin-discuss mailing list