Skip to content

Commit

Permalink
[truffle] Use the double to string conversion from graal.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Jul 25, 2018
1 parent e300cac commit d25e35c
Show file tree
Hide file tree
Showing 12 changed files with 3,849 additions and 20 deletions.
14 changes: 2 additions & 12 deletions src/vm/jvm/runtime/org/perl6/nqp/truffle/runtime/Coercions.java
@@ -1,5 +1,6 @@
package org.perl6.nqp.truffle.runtime;

import org.perl6.nqp.truffle.runtime.doubleconv.DoubleConversion;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;

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

String coerced = Double.toString(value);

int index = coerced.indexOf('E');
if (index == -1) {
return coerced;
} else {
if (coerced.charAt(index+1) == '-') {
return coerced.substring(0, index) + "e" + coerced.substring(index+1);
} else {
return coerced.substring(0, index) + "e+" + coerced.substring(index+1);
}
}
return DoubleConversion.toShortestString(value);
}
}

Expand Down

0 comments on commit d25e35c

Please sign in to comment.