diff --git a/mex/sources/bytecode/ErrorHandling.hh b/mex/sources/bytecode/ErrorHandling.hh
index 273977ac05b79c3f68491d11dbff6c491140f9b3..84a8ddbc9be68b1145afb4ca6a040527c8e1a0a2 100644
--- a/mex/sources/bytecode/ErrorHandling.hh
+++ b/mex/sources/bytecode/ErrorHandling.hh
@@ -78,7 +78,10 @@ public:
   LogExceptionHandling(double value_arg) : FloatingPointExceptionHandling("log(X)"),
                                            value(value_arg)
   {
-    completeErrorMsg(" with X=" + to_string(value) + "\n");
+    // We don’t use std::to_string(), because it uses fixed formatting
+    ostringstream s;
+    s << " with X=" << defaultfloat << value << "\n";
+    completeErrorMsg(s.str());
   }
 };
 
@@ -89,7 +92,10 @@ public:
   Log10ExceptionHandling(double value_arg) : FloatingPointExceptionHandling("log10(X)"),
                                              value(value_arg)
   {
-    completeErrorMsg(" with X=" + to_string(value) + "\n");
+    // We don’t use std::to_string(), because it uses fixed formatting
+    ostringstream s;
+    s << " with X=" << defaultfloat << value << "\n";
+    completeErrorMsg(s.str());
   }
 };
 
@@ -101,7 +107,10 @@ public:
                                                                   value1(value1_arg),
                                                                   value2(value2_arg)
   {
-    completeErrorMsg(" with X=" + to_string(value2) + "\n");
+    // We don’t use std::to_string(), because it uses fixed formatting
+    ostringstream s;
+    s << " with X=" << defaultfloat << value2 << "\n";
+    completeErrorMsg(s.str());
   }
 };
 
@@ -113,10 +122,13 @@ public:
                                                                value1(value1_arg),
                                                                value2(value2_arg)
   {
-    if (fabs(value1) > 1e-10)
-      completeErrorMsg(" with X=" + to_string(value1) + "\n");
-    else
-      completeErrorMsg(" with X=" + to_string(value1) + " and a=" + to_string(value2) + "\n");
+    // We don’t use std::to_string(), because it uses fixed formatting
+    ostringstream s;
+    s << " with X=" << defaultfloat << value1;
+    if (fabs(value1) <= 1e-10)
+      s << " and a=" << value2;
+    s << "\n";
+    completeErrorMsg(s.str());
   };
 };