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

Function mult

strings/dtoa.c:929–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

927/* Multiply two Bigint numbers */
928
929static Bigint *mult(Bigint *a, Bigint *b, Stack_alloc *alloc)
930{
931 Bigint *c;
932 int k, wa, wb, wc;
933 ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
934 ULong y;
935 ULLong carry, z;
936
937 if (a->wds < b->wds)
938 {
939 c= a;
940 a= b;
941 b= c;
942 }
943 k= a->k;
944 wa= a->wds;
945 wb= b->wds;
946 wc= wa + wb;
947 if (wc > a->maxwds)
948 k++;
949 c= Balloc(k, alloc);
950 for (x= c->p.x, xa= x + wc; x < xa; x++)
951 *x= 0;
952 xa= a->p.x;
953 xae= xa + wa;
954 xb= b->p.x;
955 xbe= xb + wb;
956 xc0= c->p.x;
957 for (; xb < xbe; xc0++)
958 {
959 if ((y= *xb++))
960 {
961 x= xa;
962 xc= xc0;
963 carry= 0;
964 do
965 {
966 z= *x++ * (ULLong)y + *xc + carry;
967 carry= z >> 32;
968 *xc++= (ULong) (z & FFFFFFFF);
969 }
970 while (x < xae);
971 *xc= (ULong) carry;
972 }
973 }
974 for (xc0= c->p.x, xc= xc0 + wc; wc > 0 && !*--xc; --wc) ;
975 c->wds= wc;
976 return c;
977}
978
979
980/*

Callers 3

pow5multFunction · 0.85
my_strtod_intFunction · 0.85
dtoaFunction · 0.85

Calls 1

BallocFunction · 0.85

Tested by

no test coverage detected