Browse Source

Added support for floating point modulo to the javascript interpreter

tags/2021-05-28
jules 7 years ago
parent
commit
f4e3eafc78
1 changed files with 4 additions and 3 deletions
  1. +4
    -3
      modules/juce_core/javascript/juce_Javascript.cpp

+ 4
- 3
modules/juce_core/javascript/juce_Javascript.cpp View File

@@ -592,14 +592,15 @@ struct JavascriptEngine::RootObject : public DynamicObject
struct DivideOp : public BinaryOperator
{
DivideOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::divide) {}
var getWithDoubles (double a, double b) const override { return b != 0.0 ? a / b : std::numeric_limits<double>::infinity(); }
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / (double) b) : var (std::numeric_limits<double>::infinity()); }
var getWithDoubles (double a, double b) const override { return b != 0 ? a / b : std::numeric_limits<double>::infinity(); }
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a / (double) b) : var (std::numeric_limits<double>::infinity()); }
};
struct ModuloOp : public BinaryOperator
{
ModuloOp (const CodeLocation& l, ExpPtr& a, ExpPtr& b) noexcept : BinaryOperator (l, a, b, TokenTypes::modulo) {}
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a % b) : var (std::numeric_limits<double>::infinity()); }
var getWithDoubles (double a, double b) const override { return b != 0 ? fmod (a, b) : std::numeric_limits<double>::infinity(); }
var getWithInts (int64 a, int64 b) const override { return b != 0 ? var (a % b) : var (std::numeric_limits<double>::infinity()); }
};
struct BitwiseOrOp : public BinaryOperator


Loading…
Cancel
Save