Browse Source

utility/cli.cpp, parseConstantDefinitionString: do constants parsing using rational number (exact)

Uses convertNumber to obtain a rational number for double constants. Additionally, improve error message if something goes wrong during conversion.
tempestpy_adaptions
JK 8 years ago
parent
commit
3c5c609e27
  1. 9
      src/storm/utility/cli.cpp

9
src/storm/utility/cli.cpp

@ -1,6 +1,7 @@
#include "storm/utility/cli.h"
#include "storm/utility/macros.h"
#include "storm/utility/constants.h"
#include "storm/exceptions/WrongFormatException.h"
namespace storm {
@ -52,8 +53,12 @@ namespace storm {
int_fast64_t integerValue = std::stoi(value);
constantDefinitions[variable] = manager.integer(integerValue);
} else if (variable.hasRationalType()) {
double doubleValue = std::stod(value);
constantDefinitions[variable] = manager.rational(doubleValue);
try {
storm::RationalNumber rationalValue = storm::utility::convertNumber<storm::RationalNumber>(value);
constantDefinitions[variable] = manager.rational(rationalValue);
} catch (std::exception& e) {
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Illegal constant definition string '" << constantName << "=" << value << "': " << e.what());
}
}
} else {
STORM_LOG_THROW(false, storm::exceptions::WrongFormatException, "Illegal constant definition string: unknown undefined constant '" << constantName << "'.");

Loading…
Cancel
Save