diff --git a/src/macro/Expressions.cc b/src/macro/Expressions.cc
index 859a6028d2ce9fa1c217ab70f4feacd04802815d..6c14152d40443324cc9a72c9066e09dfc4eae455 100644
--- a/src/macro/Expressions.cc
+++ b/src/macro/Expressions.cc
@@ -315,7 +315,11 @@ String::cast_double() const
 {
   try
     {
-      return make_shared<Double>(stod(value), env);
+      size_t pos = 0;
+      double value_d = stod(value, &pos);
+      if (pos != value.length())
+        throw StackTrace("Entire string not converted");
+      return make_shared<Double>(value_d, env);
     }
   catch (...)
     {