mirror of https://github.com/stella-emu/stella.git
Fixed divide by 0 problem. This will slow down the division expression
slighly, but better slower than crashing the program. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@643 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
39b4f91c0d
commit
c0924eaf4f
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: DivExpression.hxx,v 1.1 2005-07-13 04:26:19 urchlay Exp $
|
// $Id: DivExpression.hxx,v 1.2 2005-07-14 12:28:53 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef DIV_EXPRESSION_HXX
|
#ifndef DIV_EXPRESSION_HXX
|
||||||
|
@ -23,14 +23,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@author B. Watson
|
@author B. Watson
|
||||||
@version $Id: DivExpression.hxx,v 1.1 2005-07-13 04:26:19 urchlay Exp $
|
@version $Id: DivExpression.hxx,v 1.2 2005-07-14 12:28:53 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class DivExpression : public Expression
|
class DivExpression : public Expression
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DivExpression(Expression *left, Expression *right);
|
DivExpression(Expression *left, Expression *right);
|
||||||
int evaluate() { return myLHS->evaluate() / myRHS->evaluate(); } // FIXME: div by zero?
|
int evaluate() { int denom = myRHS->evaluate();
|
||||||
|
return denom == 0 ? 0 : myLHS->evaluate() / denom;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue