diff --git a/library/include/df/custom/coord.methods.inc b/library/include/df/custom/coord.methods.inc index a66a71919..6814be3c2 100644 --- a/library/include/df/custom/coord.methods.inc +++ b/library/include/df/custom/coord.methods.inc @@ -33,7 +33,7 @@ coord operator-(const coord &other) const coord operator/(int number) const { - return coord(x/number, y/number, z); + return coord((x < 0 ? x - number : x)/number, (y < 0 ? y - number : y)/number, z); } coord operator*(int number) const { @@ -41,7 +41,7 @@ coord operator*(int number) const } coord operator%(int number) const { - return coord(x%number, y%number, z); + return coord((x+number)%number, (y+number)%number, z); } coord operator-(int number) const diff --git a/library/include/df/custom/coord2d.methods.inc b/library/include/df/custom/coord2d.methods.inc index f617001cb..c27629458 100644 --- a/library/include/df/custom/coord2d.methods.inc +++ b/library/include/df/custom/coord2d.methods.inc @@ -29,7 +29,7 @@ coord2d operator-(const coord2d &other) const coord2d operator/(int number) const { - return coord2d(x/number, y/number); + return coord2d((x < 0 ? x - number : x)/number, (y < 0 ? y - number : y)/number); } coord2d operator*(int number) const { @@ -37,5 +37,5 @@ coord2d operator*(int number) const } coord2d operator%(int number) const { - return coord2d(x%number, y%number); + return coord2d((x+number)%number, (y+number)%number); }