| 751 | /* Multiply by m and add a */ |
| 752 | |
| 753 | static Bigint *multadd(Bigint *b, int m, int a, Stack_alloc *alloc) |
| 754 | { |
| 755 | int i, wds; |
| 756 | ULong *x; |
| 757 | ULLong carry, y; |
| 758 | Bigint *b1; |
| 759 | |
| 760 | wds= b->wds; |
| 761 | x= b->p.x; |
| 762 | i= 0; |
| 763 | carry= a; |
| 764 | do |
| 765 | { |
| 766 | y= *x * (ULLong)m + carry; |
| 767 | carry= y >> 32; |
| 768 | *x++= (ULong)(y & FFFFFFFF); |
| 769 | } |
| 770 | while (++i < wds); |
| 771 | if (carry) |
| 772 | { |
| 773 | if (wds >= b->maxwds) |
| 774 | { |
| 775 | b1= Balloc(b->k+1, alloc); |
| 776 | Bcopy(b1, b); |
| 777 | Bfree(b, alloc); |
| 778 | b= b1; |
| 779 | } |
| 780 | b->p.x[wds++]= (ULong) carry; |
| 781 | b->wds= wds; |
| 782 | } |
| 783 | return b; |
| 784 | } |
| 785 | |
| 786 | /** |
| 787 | Converts a string to Bigint. |