Skip to content

Commit 457e7dc

Browse files
committed
DF/PT fix for full JavaScript double precision
1 parent 1e85d01 commit 457e7dc

File tree

7 files changed

+14
-6
lines changed

7 files changed

+14
-6
lines changed
-23 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220118080745
1+
20220122050025
-23 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20220118080745
1+
20220122050025
94 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/javajs/util/DF.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ public static String formatDecimalDbl(double value, int decimalDigits) {
6969
* @return formatted decimal
7070
*/
7171
public static String formatDecimal(double value, int decimalDigits) {
72-
if (decimalDigits == Integer.MAX_VALUE
73-
|| value == Double.NEGATIVE_INFINITY || value == Double.POSITIVE_INFINITY || Double.isNaN(value))
74-
return "" + value;
72+
if (value == Double.NEGATIVE_INFINITY || value == Double.POSITIVE_INFINITY || Double.isNaN(value))
73+
return "" + value;
74+
if (decimalDigits == Integer.MAX_VALUE)
75+
return "" + (float) value;
7576
boolean isNeg = (value < 0);
7677
if (isNeg)
7778
value = -value;

sources/net.sf.j2s.java.core/src/javajs/util/PT.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,14 @@ else if (exponent != 0)
216216
0.000001f,
217217
0.0000001f,
218218
0.00000001f,
219-
0.000000001f
219+
0.000000001f,
220+
// added for JavaScript to have full double precision if specified
221+
0.0000000001f,
222+
0.00000000001f,
223+
0.000000000001f,
224+
0.0000000000001f,
225+
0.00000000000001f,
226+
0.000000000000001f,
220227
};
221228
public static boolean checkTrailingText(String str, int ich, int ichMax) {
222229
//number must be pure -- no additional characters other than white space or ;

0 commit comments

Comments
 (0)