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.
| 798 | @param alloc Stack allocator for Bigints. |
| 799 | */ |
| 800 | static 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 | |
| 830 | static int hi0bits(register ULong x) |
no test coverage detected