| 1127 | |
| 1128 | |
| 1129 | static Bigint *diff(Bigint *a, Bigint *b, Stack_alloc *alloc) |
| 1130 | { |
| 1131 | Bigint *c; |
| 1132 | int i, wa, wb; |
| 1133 | ULong *xa, *xae, *xb, *xbe, *xc; |
| 1134 | ULLong borrow, y; |
| 1135 | |
| 1136 | i= cmp(a,b); |
| 1137 | if (!i) |
| 1138 | { |
| 1139 | c= Balloc(0, alloc); |
| 1140 | c->wds= 1; |
| 1141 | c->p.x[0]= 0; |
| 1142 | return c; |
| 1143 | } |
| 1144 | if (i < 0) |
| 1145 | { |
| 1146 | c= a; |
| 1147 | a= b; |
| 1148 | b= c; |
| 1149 | i= 1; |
| 1150 | } |
| 1151 | else |
| 1152 | i= 0; |
| 1153 | c= Balloc(a->k, alloc); |
| 1154 | c->sign= i; |
| 1155 | wa= a->wds; |
| 1156 | xa= a->p.x; |
| 1157 | xae= xa + wa; |
| 1158 | wb= b->wds; |
| 1159 | xb= b->p.x; |
| 1160 | xbe= xb + wb; |
| 1161 | xc= c->p.x; |
| 1162 | borrow= 0; |
| 1163 | do |
| 1164 | { |
| 1165 | y= (ULLong)*xa++ - *xb++ - borrow; |
| 1166 | borrow= y >> 32 & (ULong)1; |
| 1167 | *xc++= (ULong) (y & FFFFFFFF); |
| 1168 | } |
| 1169 | while (xb < xbe); |
| 1170 | while (xa < xae) |
| 1171 | { |
| 1172 | y= *xa++ - borrow; |
| 1173 | borrow= y >> 32 & (ULong)1; |
| 1174 | *xc++= (ULong) (y & FFFFFFFF); |
| 1175 | } |
| 1176 | while (!*--xc) |
| 1177 | wa--; |
| 1178 | c->wds= wa; |
| 1179 | return c; |
| 1180 | } |
| 1181 | |
| 1182 | |
| 1183 | static double ulp(U *x) |
no test coverage detected