When dividing by 1000, I someday encounter an error that does not make the division โrightโ. For example, dividing 90.55 by 1000 instead of getting .09055 I get .090549999999.
<c:out value="${bean.paPrice / 1000}" />
Why is this happening? Is this the result of floating point math? It seems that a Google search showed that this could be a criminal, but I did not find a specific answer.
To fix this, I can round the answer to 5 digits, but it looks like this is just a patch for a deeper problem.
<fmt:formatNumber type="number" maxFractionDigits="5" value="${bean.paPrice / 1000}" />
source
share