diff --git a/macro/MacroBison.yy b/macro/MacroBison.yy
index 2bd8072a4c598e7a661e01280566ce43877f0d93..27c0e4b28c11dc61735eee686730545d698b054e 100644
--- a/macro/MacroBison.yy
+++ b/macro/MacroBison.yy
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2014 Dynare Team
+ * Copyright (C) 2008-2016 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -150,7 +150,12 @@ expr : INTEGER
      | expr TIMES expr
        { TYPERR_CATCH($$ = *$1 * *$3, @$); }
      | expr DIVIDE expr
-       { TYPERR_CATCH($$ = *$1 / *$3, @$); }
+       {
+         if (dynamic_cast<const IntMV *>($3) != NULL
+             && ((IntMV *)$3)->get_int_value() == 0)
+           driver.error(@$, "Division by zero");
+         TYPERR_CATCH($$ = *$1 / *$3, @$);
+       }
      | expr LESS expr
        { TYPERR_CATCH($$ = *$1 < *$3, @$); }
      | expr GREATER expr
diff --git a/macro/MacroValue.hh b/macro/MacroValue.hh
index 25016478120b5a4e1bbe2dd9e3249a8c7fb7b597..c9da9c3ddf2697e7b2be026968692e464b6b2429 100644
--- a/macro/MacroValue.hh
+++ b/macro/MacroValue.hh
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2013 Dynare Team
+ * Copyright (C) 2008-2016 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -158,6 +158,7 @@ public:
     If mv2 < mv1, returns an empty range (for consistency with MATLAB).
   */
   static const MacroValue *new_range(MacroDriver &driver, const MacroValue *mv1, const MacroValue *mv2) throw (TypeError);
+  inline int get_int_value() const { return value; };
 };
 
 //! Represents a string value in macro language