-
Type:
Feature Request
-
Resolution: Unresolved
-
Priority:
L3 - Default
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
AT:
- I can submit floating point numbers via REST API and use them in DMN tables without loosing precision
Implementation notes:
- This can be solved by deserializing floating point numbers to BigDecimal
- Testing/Extending the DMN engine that it treats BigDecimal like other numbers
Original post:
I've downloaded the camunda bpm platform in order to evaluate dmn decisions by using the rest api.
For that I deploy this decision table:
And send this json request:
{ "variables": { "a": { "value": 100.01 }, "b": { "value": 10.01 } } }
I receive the following response:
[ { "result": { "type": "Double", "value": 110.02000000000001, "valueInfo": {} } } ]
I expect that the value of "result" were "110.02" but instead it gives "110.02000000000001". The issue is that camunda "engine-rest" receives numbers as "Double", so by making a sum it looses precision.
I'd like to propose a modification to the class org.camunda.bpm.engine.rest.mapper.JacksonConfigurator to:
... public class JacksonConfigurator implements ContextResolver<ObjectMapper> { ... public static ObjectMapper configureObjectMapper(ObjectMapper mapper) { SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString); mapper.setDateFormat(dateFormat); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); // add this line return mapper; } ... }
Added line :
mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
This modification makes json to convert numbers into BigDecimal in order to not loose precision after doing operations over these numbers.
Can anyone tell me how to push this modification request? Thanks in advance.