ref: cda7129cd28a25832ad06ed939d32fce9413db63
parent: 98a5fc6535a10e292f0fa1ad5aed7f10a963ce19
author: aiju <devnull@localhost>
date: Thu May 3 19:31:24 EDT 2018
mplogic: don't drop carry out
--- a/sys/src/libmp/port/mplogic.c
+++ b/sys/src/libmp/port/mplogic.c
@@ -36,7 +36,7 @@
b2 = t;
fl = fl >> 2 & 0x03 | fl << 2 & 0x0c | fl & 0x30;
}
- mpbits(sum, b1->top*Dbits);
+ mpbits(sum, b1->top*Dbits+1);
dp1 = b1->p;
dp2 = b2->p;
dpo = sum->p;
@@ -60,6 +60,8 @@
dpo[i] = d;
}
sum->top = i;
+ if(co)
+ dpo[sum->top++] = co;
mpnorm(sum);
}
@@ -105,7 +107,7 @@
}
fl = (b1->sign & 10) ^ (b2->sign & 12);
sum->sign = (int)(fl << 28) >> 31 | 1;
- mpbits(sum, b1->top*Dbits);
+ mpbits(sum, b1->top*Dbits+1);
dp1 = b1->p;
dp2 = b2->p;
dpo = sum->p;
@@ -126,6 +128,8 @@
dpo[i] = d;
}
sum->top = i;
+ if(co)
+ dpo[sum->top++] = co;
mpnorm(sum);
}