[Coin-discuss] Problem with MPS export / MSVC
Jörg Herbers
herbers at hotmail.com
Thu Mar 25 10:11:18 EST 2004
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
dont 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
More information about the Coin-discuss
mailing list