#62 Parsing double

jsbml 0.8

The method parseSBMLDouble(String) in the class StringTools.java is used to parse string values into
double values. The method works correct, but for my needs to correct.
In the following SBML snippet is a list of Parameters in KineticLaw.

<parameter id="Vf" value="1,43" />
<parameter id="Kma" value=",059" />

In this parameters values like ,4 and 0,4 are set for the attribute value.

,4 is a expression for 0.4
0,4 is a expression for 0.4

The method returns Double.NAN for both expression. Developers have no oppotunity to get this not correct
double values.

I have got two suggestions. You could add code to the method to transform this cases into a valid double value.
I would suggest the following change for the method parseSBMLDouble:

public static double parseSBMLDouble(String valueAsStr) {

double value = Double.NaN;
String toTest = valueAsStr.trim();

try {
toTest = toTest.replace(",", "0.");
else if(toTest.startsWith(".")){
toTest = toTest.replace(".", "0.");
else if(toTest.contains(",")){
toTest = toTest.replace(",", ".");
value = Double.parseDouble(toTest);
} catch (NumberFormatException e) {

if (toTest.equalsIgnoreCase("INF")) {
} else if (toTest.equalsIgnoreCase("-INF")) {
} else {
Logger logger = Logger.getLogger(StringTools.class);
logger.warn("Could not create a double from the string " + valueAsStr);

return value;

As a alternative I would like to get the wrong double thrown by an exception.


  • Nicolas Rodriguez

    The problem here is that your SBML file as to comply to the SBML specifications and we consider a valid double value, only the values that are defined in the SBML specifications.
    You can check the SBML specifications, for example level 2 version 4 or Level 3 version 1 core, section 3.1.5 about the primitive data types and specifically the double type. The comma is not accepted as a valid separator, so the numbers would not be understood by many software.

    You could change the Locale in your java application so that numbers set into jsbml objects are of the right form.

  • Nicolas Rodriguez

    • assigned_to: nobody --> niko-rodrigue
    • status: open --> pending-wont-fix
  • Nicolas Rodriguez

    We are currently discussing if we should try to deal with this problem inside JSBML or not, in fact.

  • Nicolas Rodriguez

    • status: pending-wont-fix --> pending
  • Nicolas Rodriguez

    • status: pending --> closed-wont-fix
    • Group: --> jsbml 0.8

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks