diff --git a/DataTree.cc b/DataTree.cc
index 4f3ad4a36e9411d75eb8a45714fb29d4b93951a3..87052a6e18ecc511fc8531d8cd5e2063e2e8bce7 100644
--- a/DataTree.cc
+++ b/DataTree.cc
@@ -51,7 +51,7 @@ DataTree::~DataTree()
 }
 
 expr_t
-DataTree::AddNonNegativeConstant(const string &value)
+DataTree::AddNonNegativeConstant(const string &value) throw (NumericalConstants::InvalidFloatingPointNumberException)
 {
   int id = num_constants.AddNonNegativeConstant(value);
 
diff --git a/DataTree.hh b/DataTree.hh
index 1a8b9f6de5e4271e197fffb3d331c98fd4e9378b..1456e9c86f617ae97b88ec0dde4794a3fee06944 100644
--- a/DataTree.hh
+++ b/DataTree.hh
@@ -110,7 +110,7 @@ public:
   };
 
   //! Adds a non-negative numerical constant (possibly Inf or NaN)
-  expr_t AddNonNegativeConstant(const string &value);
+  expr_t AddNonNegativeConstant(const string &value) throw (NumericalConstants::InvalidFloatingPointNumberException);
   //! Adds a variable
   /*! The default implementation of the method refuses any lag != 0 */
   virtual VariableNode *AddVariable(int symb_id, int lag = 0);
diff --git a/NumericalConstants.cc b/NumericalConstants.cc
index 58f1d2822912b3ffe1479618493e734e2778a532..6efe1fc06e01503efcf6f0f9858e74e858c1322a 100644
--- a/NumericalConstants.cc
+++ b/NumericalConstants.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2010 Dynare Team
+ * Copyright (C) 2003-2011 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -26,7 +26,7 @@
 #include "NumericalConstants.hh"
 
 int
-NumericalConstants::AddNonNegativeConstant(const string &iConst)
+NumericalConstants::AddNonNegativeConstant(const string &iConst) throw (InvalidFloatingPointNumberException)
 {
   map<string, int>::const_iterator iter = numConstantsIndex.find(iConst);
 
@@ -39,7 +39,11 @@ NumericalConstants::AddNonNegativeConstant(const string &iConst)
 
   errno = 0;
   double val = strtod(iConst.c_str(), NULL);
-  assert(errno == 0); // Check that the conversion succeeded
+
+  // We check that the number is valid (e.g. not like "1e-10000")
+  if (errno != 0)
+    throw InvalidFloatingPointNumberException(iConst);
+
   assert(val >= 0 || isnan(val)); // Check we have a positive constant or a NaN
   double_vals.push_back(val);
 
diff --git a/NumericalConstants.hh b/NumericalConstants.hh
index ceacc94b9bafc67c6f1f915da4d1426162a3af4e..0a54616a23fbacc27b7eb6134991c28ea09ef020 100644
--- a/NumericalConstants.hh
+++ b/NumericalConstants.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2010 Dynare Team
+ * Copyright (C) 2003-2011 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -37,8 +37,15 @@ private:
   //! Map matching constants to their id
   map<string, int> numConstantsIndex;
 public:
+  class InvalidFloatingPointNumberException
+  {
+  public:
+    const string fp;
+    InvalidFloatingPointNumberException(const string &fp_arg) : fp(fp_arg) {}
+  };
+
   //! Adds a non-negative constant (possibly Inf or NaN) and returns its ID
-  int AddNonNegativeConstant(const string &iConst);
+  int AddNonNegativeConstant(const string &iConst) throw (InvalidFloatingPointNumberException);
   //! Get a constant in string form
   string get(int ID) const;
   //! Get a constant in double form
diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index 214cbf84b54fd0b81f0ba8be34d659b167ce264d..7fb56ce7d63878b629ab3a7ac3a3044f03e96ab5 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -227,7 +227,15 @@ ParsingDriver::add_equation_tags(string *key, string *value)
 expr_t
 ParsingDriver::add_non_negative_constant(string *constant)
 {
-  expr_t id = data_tree->AddNonNegativeConstant(*constant);
+  expr_t id;
+  try
+    {
+      id = data_tree->AddNonNegativeConstant(*constant);
+    }
+  catch (NumericalConstants::InvalidFloatingPointNumberException &e)
+    {
+      error("Invalid floating point number: " + *constant);
+    }
   delete constant;
   return id;
 }
@@ -703,10 +711,18 @@ void
 ParsingDriver::add_value(string *v)
 {
   expr_t id;
-  if (v->at(0) == '-')
-    id = data_tree->AddUMinus(data_tree->AddNonNegativeConstant(v->substr(1, string::npos)));
-  else
-    id = data_tree->AddNonNegativeConstant(*v);
+  try
+    {
+      if (v->at(0) == '-')
+        id = data_tree->AddUMinus(data_tree->AddNonNegativeConstant(v->substr(1, string::npos)));
+      else
+        id = data_tree->AddNonNegativeConstant(*v);
+    }
+  catch (NumericalConstants::InvalidFloatingPointNumberException &e)
+    {
+      error("Invalid floating point number: " + *v);
+    }
+
   delete v;
   det_shocks_values.push_back(id);
 }
@@ -817,10 +833,18 @@ void
 ParsingDriver::add_to_row_const(string *v)
 {
   expr_t id;
-  if (v->at(0) == '-')
-    id = data_tree->AddUMinus(data_tree->AddNonNegativeConstant(v->substr(1, string::npos)));
-  else
-    id = data_tree->AddNonNegativeConstant(*v);
+  try
+    {
+      if (v->at(0) == '-')
+        id = data_tree->AddUMinus(data_tree->AddNonNegativeConstant(v->substr(1, string::npos)));
+      else
+        id = data_tree->AddNonNegativeConstant(*v);
+    }
+  catch (NumericalConstants::InvalidFloatingPointNumberException &e)
+    {
+      error("Invalid floating point number: " + *v);
+    }
+
   delete v;
   sigmae_row.push_back(id);
 }