Skip to content

precision loss of double/float value in dmn-engine #4065

@EdmondRui

Description

@EdmondRui

Description:
Using double/float input data to execute a dmn decision table, the double/float input got prevcision loss。

Version:
Flowable Version: 6.5.0

Code:
code snippet in ELExecutionContextBuilder.java

} else if (inputVariableValue instanceof Double ) {
    BigDecimal transformedNumber = new BigDecimal((Double) inputVariableValue);
    inputVariables.put(inputVariableName, transformedNumber);
} else if (inputVariableValue instanceof Float) {
    double doubleValue = Double.parseDouble(inputVariableValue.toString());
    BigDecimal transformedNumber = new BigDecimal(doubleValue);
    inputVariables.put(inputVariableName, transformedNumber);
}

Additional comments:
i think the best way is using BigDecimal.valueOf(val) or new BigDecimal(Double.toString(val))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions