How do I parse strings as literal double values? I have a set of probability values I am parsing using Double.valueOf(probabilityString) that need to sum exactly to 1.0d.
For example, the resulting sum of the double values is 0.999999... when the probability strings are 0.2, 0.5, 0.2, 0.1.
What I would like to have is for the double values to be parsed in as 0.2d, 0.5d, 0.2d, 0.1d, is this possible?
I am dealing with a third-party library that accepts double[] as argument and throws an exception if the double values do not sum up precisely to 1.0d.