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

Function d2b

strings/dtoa.c:1234–1281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1232
1233
1234static Bigint *d2b(U *d, int *e, int *bits, Stack_alloc *alloc)
1235{
1236 Bigint *b;
1237 int de, k;
1238 ULong *x, y, z;
1239 int i;
1240#define d0 word0(d)
1241#define d1 word1(d)
1242
1243 b= Balloc(1, alloc);
1244 x= b->p.x;
1245
1246 z= d0 & Frac_mask;
1247 d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
1248 if ((de= (int)(d0 >> Exp_shift)))
1249 z|= Exp_msk1;
1250 if ((y= d1))
1251 {
1252 if ((k= lo0bits(&y)))
1253 {
1254 x[0]= y | z << (32 - k);
1255 z>>= k;
1256 }
1257 else
1258 x[0]= y;
1259 i= b->wds= (x[1]= z) ? 2 : 1;
1260 }
1261 else
1262 {
1263 k= lo0bits(&z);
1264 x[0]= z;
1265 i= b->wds= 1;
1266 k+= 32;
1267 }
1268 if (de)
1269 {
1270 *e= de - Bias - (P-1) + k;
1271 *bits= P - k;
1272 }
1273 else
1274 {
1275 *e= de - Bias - (P-1) + 1 + k;
1276 *bits= 32*i - hi0bits(x[i-1]);
1277 }
1278 return b;
1279#undef d0
1280#undef d1
1281}
1282
1283
1284static double ratio(Bigint *a, Bigint *b)

Callers 2

my_strtod_intFunction · 0.85
dtoaFunction · 0.85

Calls 3

BallocFunction · 0.85
lo0bitsFunction · 0.85
hi0bitsFunction · 0.85

Tested by

no test coverage detected