Commit 14da938e authored by Cerlane Leong's avatar Cerlane Leong 💬

Bug fix

parent 842a45dc
......@@ -186,19 +186,17 @@ quire32_t q32_fdp_sub( quire32_t q, posit32_t pA, posit32_t pB ){
for (i=7; i>=0; i--){
b1 = uZ1.ui[i] & 0x1;
b2 = uZ2.ui[i] & 0x1;
rcarryb = b1 & b2;
uZ.ui[i] = (uZ1.ui[i]>>1) + (uZ2.ui[i]>>1) + rcarryb;
int_fast8_t rcarryb3;
if (i<7){
rcarryb3 = b1 + b2 + rcarryZ;
uZ.ui[i] += ((rcarryb3>>1)& 0x1);
if (i==7){
rcarryb = b1 & b2;
uZ.ui[i] = (uZ1.ui[i]>>1) + (uZ2.ui[i]>>1) + rcarryb;
rcarryZ = uZ.ui[i]>>63;
uZ.ui[i] = (uZ.ui[i]<<1 | (rcarryb3 & 0x1) );
uZ.ui[i] = (uZ.ui[i]<<1 | (b1^b2) );
}
else{
int_fast8_t rcarryb3 = b1 + b2 + rcarryZ;
uZ.ui[i] = (uZ1.ui[i]>>1) + (uZ2.ui[i]>>1) + (rcarryb3>>1);
rcarryZ = uZ.ui[i]>>63;
uZ.ui[i] = (uZ.ui[i]<<1 | (b1^b2) );
uZ.ui[i] = (uZ.ui[i]<<1 | (rcarryb3 & 0x1) );
}
}
......@@ -217,6 +215,6 @@ quire32_t q32_fdp_sub( quire32_t q, posit32_t pA, posit32_t pB ){
}
//Exception handling
if (isNaRQ32(uZ.q) ) uZ.q = q32_clr(uZ.q);
return uZ.q;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment