Skip to content

Commit d25e35c

Browse files
committed
[truffle] Use the double to string conversion from graal.js
1 parent e300cac commit d25e35c

File tree

12 files changed

+3849
-20
lines changed

12 files changed

+3849
-20
lines changed

src/vm/jvm/runtime/org/perl6/nqp/truffle/runtime/Coercions.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.perl6.nqp.truffle.runtime;
22

3+
import org.perl6.nqp.truffle.runtime.doubleconv.DoubleConversion;
34
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
45

56
public class Coercions {
@@ -19,18 +20,7 @@ public static String numToStr(double value) {
1920
if (value != value)
2021
return "NaN";
2122

22-
String coerced = Double.toString(value);
23-
24-
int index = coerced.indexOf('E');
25-
if (index == -1) {
26-
return coerced;
27-
} else {
28-
if (coerced.charAt(index+1) == '-') {
29-
return coerced.substring(0, index) + "e" + coerced.substring(index+1);
30-
} else {
31-
return coerced.substring(0, index) + "e+" + coerced.substring(index+1);
32-
}
33-
}
23+
return DoubleConversion.toShortestString(value);
3424
}
3525
}
3626

0 commit comments

Comments
 (0)