summaryrefslogtreecommitdiff
path: root/big.c
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-03-28 14:11:39 -0400
committerJakob Kaivo <jkk@ung.org>2022-03-28 14:11:39 -0400
commitdb28fcf89f08307ca5f13cbb9d562ac0e5f9431e (patch)
treebe5ec8a162f685aa01e5dfc5df05b7e2341b9d20 /big.c
parent1b3e4865fcca40e49d02fe2878c3173de92087cc (diff)
modernize bigsub()
Diffstat (limited to 'big.c')
-rw-r--r--big.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/big.c b/big.c
index f791b4d..c35ce99 100644
--- a/big.c
+++ b/big.c
@@ -155,18 +155,20 @@ word big_plus(word x, word y, int signbit)
return r;
}
-word bigsub(x, y)
-word x, y;
+word bigsub(word x, word y)
{
- if (big_is_positive(x))
- if (big_is_positive(y))
- return (big_sub(x, y));
- else
- return (big_plus(x, y, 0)); /* big_is_positive x, negative y */
- else if (big_is_positive(y))
- return (big_plus(x, y, SIGNBIT)); /* negative x, big_is_positive y */
- else
- return (big_sub(y, x)); /* both negative */
+ if (big_is_positive(x)) {
+ if (big_is_positive(y)) {
+ return (big_sub(x, y)); /* both positive */
+ }
+ return (big_plus(x, y, 0)); /* positive x, negative y */
+ }
+
+ if (big_is_positive(y)) {
+ return (big_plus(x, y, SIGNBIT)); /* negative x, positive y */
+ }
+
+ return (big_sub(y, x)); /* both negative */
}
word big_sub(x, y) /* ignore input signs, treat x,y as positive */