Skip to content

Commit

Permalink
Merge pull request #2238 from mgreter/bugfix/issue-2236
Browse files Browse the repository at this point in the history
Fix modulo operation to behave as ruby sass
  • Loading branch information
mgreter authored Dec 7, 2016
2 parents 0443d7f + b6c39e1 commit 5b92405
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ namespace Sass {
inline double sub(double x, double y) { return x - y; }
inline double mul(double x, double y) { return x * y; }
inline double div(double x, double y) { return x / y; } // x/0 checked by caller
inline double mod(double x, double y) { return std::abs(std::fmod(x, y)); } // x/0 checked by caller
inline double mod(double x, double y) { // x/0 checked by caller
if ((x > 0 && y < 0) || (x < 0 && y > 0)) {
double ret = std::fmod(x, y);
return ret ? ret + y : ret;
} else {
return std::fmod(x, y);
}
}
typedef double (*bop)(double, double);
bop ops[Sass_OP::NUM_OPS] = {
0, 0, // and, or
Expand Down

0 comments on commit 5b92405

Please # to comment.