for (n = 1; n < nptr; n++) {
int temp;
+ div_t q;
+
if (!is_integer(ptr[n])) {
safe_str(T(e_ints), buff, bp);
return;
return;
}
- if (divresult < 0) {
- if (temp < 0)
- divresult = -divresult / -temp;
- else
- divresult = -(-divresult / temp);
- } else {
- if (temp < 0)
- divresult = -(divresult / -temp);
- else
- divresult = divresult / temp;
+ if (divresult == INT_MAX && temp == -1) {
+ safe_str(T("#-1 DOMAIN ERROR"), buff, bp);
+ return;
}
+
+ q = div(divresult, temp);
+ divresult = q.quot;
}
safe_integer(divresult, buff, bp);
}
return;
}
+ if (divresult == INT_MIN && temp == -1) {
+ safe_str(T("#-1 DOMAIN ERROR"), buff, bp);
+ return;
+ }
+
if (divresult < 0) {
if (temp < 0)
divresult = -divresult / -temp;
return;
}
+ if (divresult == INT_MIN && temp == -1) {
+ safe_str(T("#-1 DOMAIN ERROR"), buff, bp);
+ return;
+ }
+
if (divresult < 0) {
if (temp < 0)
divresult = -(-divresult % -temp);
for (n = 1; n < nptr; n++) {
int temp;
+ div_t r;
+
if (!is_integer(ptr[n])) {
safe_str(T(e_ints), buff, bp);
return;
return;
}
- if (divresult < 0) {
- if (temp < 0)
- divresult = -(-divresult % -temp);
- else
- divresult = -(-divresult % temp);
- } else {
- if (temp < 0)
- divresult = divresult % -temp;
- else
- divresult = divresult % temp;
+ if (divresult == INT_MIN && temp == -1) {
+ safe_str(T("#-1 DOMAIN ERROR"), buff, bp);
+ return;
}
+
+ r = div(divresult, temp);
+ divresult = r.rem;
}
safe_integer(divresult, buff, bp);
}