summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/mathop.h
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-04-03 22:35:04 +0000
committerKarl Berry <karl@freefriends.org>2018-04-03 22:35:04 +0000
commit36b8d1341af4a7ab1f5759d75ad1eecfc375c1f4 (patch)
tree12d09b686d2c18f245dc6fd492c09cdcd4c02ebc /Build/source/utils/asymptote/mathop.h
parentd73e029b665b866fe734e44508746a2cba513fd7 (diff)
asy 2.42 sources
git-svn-id: svn://tug.org/texlive/trunk@47274 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/mathop.h')
-rw-r--r--Build/source/utils/asymptote/mathop.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/Build/source/utils/asymptote/mathop.h b/Build/source/utils/asymptote/mathop.h
index 1fda216e592..cdacdf938f9 100644
--- a/Build/source/utils/asymptote/mathop.h
+++ b/Build/source/utils/asymptote/mathop.h
@@ -238,21 +238,23 @@ struct power<Int> {
}
};
-template <typename T>
+template <typename>
struct mod {
- T operator() (T x, T y, size_t i=0) {
+ Int operator() (Int x, Int y, size_t i=0) {
if(y == 0) dividebyzero(i);
return portableMod(x,y);
}
};
-template <typename T>
+template <typename>
struct quotient {
- T operator() (T x, T y, size_t i=0) {
+ Int operator() (Int x, Int y, size_t i=0) {
if(y == 0) dividebyzero(i);
if(y == -1) return Negate(x);
// Implementation-independent definition of integer division: round down
- return (x-portableMod(x,y))/y;
+ Int q=x/y;
+ if(q >= 0 || y*q == x) return q;
+ return q-1;
}
};