MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / multadd

Function multadd

strings/dtoa.c:753–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

751/* Multiply by m and add a */
752
753static 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.

Callers 3

s2bFunction · 0.85
pow5multFunction · 0.85
dtoaFunction · 0.85

Calls 2

BallocFunction · 0.85
BfreeFunction · 0.85

Tested by

no test coverage detected