Bryan O'Sullivan avatar Bryan O'Sullivan committed c557bee

Use our own converter that doesn't need to follow JS rules.

Comments (0)

Files changed (1)

cbits/hs-double-conversion.cc

   return pos;
 }
 
+static inline const DoubleToStringConverter& defaultConverter(void)
+{
+  const int flags = DoubleToStringConverter::UNIQUE_ZERO;
+  static DoubleToStringConverter converter(flags,
+                                           "Infinity",
+                                           "NaN",
+                                           'e',
+                                           -6, 21,
+                                           6, 0);
+  return converter;
+}
+
 extern "C"
 int _hs_ToShortest(double value, uint16_t *buf)
 {
-  const DoubleToStringConverter& converter =
-    DoubleToStringConverter::EcmaScriptConverter();
   char cbuf[kToShortestLength];
-
   StringBuilder builder(cbuf, kToShortestLength);
-  bool ok = converter.ToShortest(value, &builder);
+  bool ok = defaultConverter().ToShortest(value, &builder);
 
   if (!ok)
     return -1;
 extern "C"
 int _hs_ToFixed(double value, uint16_t *buf, const int ndigits)
 {
-  const DoubleToStringConverter& converter =
-    DoubleToStringConverter::EcmaScriptConverter();
   char cbuf[kToFixedLength];
-
   StringBuilder builder(cbuf, kToFixedLength);
-  bool ok = converter.ToFixed(value, ndigits, &builder);
+  bool ok = defaultConverter().ToFixed(value, ndigits, &builder);
 
   if (!ok)
     return -1;
 extern "C"
 int _hs_ToExponential(double value, uint16_t *buf, const int ndigits)
 {
-  const DoubleToStringConverter& converter =
-    DoubleToStringConverter::EcmaScriptConverter();
   char cbuf[kToExponentialLength];
-
   StringBuilder builder(cbuf, kToExponentialLength);
-  bool ok = converter.ToExponential(value, ndigits, &builder);
+  bool ok = defaultConverter().ToExponential(value, ndigits, &builder);
 
   if (!ok)
     return -1;
 extern "C"
 int _hs_ToPrecision(double value, uint16_t *buf, const int precision)
 {
-  const DoubleToStringConverter& converter =
-    DoubleToStringConverter::EcmaScriptConverter();
   char cbuf[kToPrecisionLength];
-
   StringBuilder builder(cbuf, kToPrecisionLength);
-  bool ok = converter.ToPrecision(value, precision, &builder);
+  bool ok = defaultConverter().ToPrecision(value, precision, &builder);
 
   if (!ok)
     return -1;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.