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

Function s2b

strings/dtoa.c:800–827  ·  view source on GitHub ↗

Converts a string to Bigint. Now we have nd0 digits, starting at s, followed by a decimal point, followed by nd-nd0 digits. Unless nd0 == nd, in which case we have a number of the form: ".xxxxxx" or "xxxxxx." @param s Input string, already partially parsed by my_strtod_int(). @param nd0 Number of digits before decimal point. @param nd Total number of digits.

Source from the content-addressed store, hash-verified

798 @param alloc Stack allocator for Bigints.
799 */
800static Bigint *s2b(const char *s, int nd0, int nd, ULong y9, Stack_alloc *alloc)
801{
802 Bigint *b;
803 int i, k;
804 Long x, y;
805
806 x= (nd + 8) / 9;
807 for (k= 0, y= 1; x > y; y <<= 1, k++) ;
808 b= Balloc(k, alloc);
809 b->p.x[0]= y9;
810 b->wds= 1;
811
812 i= 9;
813 if (9 < nd0)
814 {
815 s+= 9;
816 do
817 b= multadd(b, 10, *s++ - '0', alloc);
818 while (++i < nd0);
819 s++; /* skip '.' */
820 }
821 else
822 s+= 10;
823 /* now do the fractional part */
824 for(; i < nd; i++)
825 b= multadd(b, 10, *s++ - '0', alloc);
826 return b;
827}
828
829
830static int hi0bits(register ULong x)

Callers 1

my_strtod_intFunction · 0.85

Calls 2

BallocFunction · 0.85
multaddFunction · 0.85

Tested by

no test coverage detected