Zeroes being erroneously stripped by DataWriterUtil.java changing value
benclarktd opened this issue · 1 comments
benclarktd commented
I am using
<dependency> <groupId>com.epam</groupId> <artifactId>parso</artifactId> <version>2.0.14</version> </dependency>
in my pom.xml
On line 232 of com.epam.parso.DataWriterUtil.java it seems numbers like 2.09186791907914E10 are having the zero stripped from the exponent becoming 2.09186791907914E1
The code doing this seems to be:
private static String trimZerosFromEnd(String string) { return string.contains(".") ? string.replaceAll("0*$", "").replaceAll("\\.$", "") : string; }
which I believe should read
private static String trimZerosFromEnd(String string) { return string.contains(".") && (! string.contains("E")) ? string.replaceAll("0*$", "").replaceAll("\\.$", "") : string; }
benclarktd commented
I made the fix to DataWriterUtil.java and recompiled the parso jar using it. Here's what I ultimately did that worked.
private static String trimZerosFromEnd(String string) { if (string.contains(".")) { if (string.contains("E")) { String preDot = string.replaceAll("^([^.]*)[.].*$", "$1"); String postDot = string.replaceAll(".*[.](.*)$", "$1"); return preDot.replaceAll("0*$", "").replaceAll("\\.$", "") + "." + postDot; } return string.replaceAll("0*$", "").replaceAll("\\.$", ""); } return string; }