mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
WIP str to bignum
This commit is contained in:
parent
c2c637134f
commit
e2d903e8dc
2 changed files with 12 additions and 3 deletions
|
@ -1608,7 +1608,7 @@ void Cyc_int2bignum(int n, mp_int *bn);
|
|||
object Cyc_int2bignum2(gc_thread_data *data, int n);
|
||||
// TODO: debug only, remove this function from here!
|
||||
string_type *bignum2string(void *data, bignum2_type *bn, int base);
|
||||
object str_to_bignum(void *data, object bignum, char *str, char *str_end, int radix);
|
||||
void _str_to_bignum(void *data, char *str, *char *str_end, int radix);
|
||||
object bignum2_plus_unsigned(void *data, bignum2_type *x, bignum2_type *y, int negp);
|
||||
|
||||
/* Remaining GC prototypes that require objects to be defined */
|
||||
|
|
13
runtime.c
13
runtime.c
|
@ -2948,13 +2948,22 @@ inline static int hex_char_to_digit(int ch)
|
|||
else return ch - (int)'0'; /* decimal (OR INVALID; handled elsewhere) */
|
||||
}
|
||||
|
||||
void _str_to_bignum(void *data, char *str, *char *str_end, int radix)
|
||||
{
|
||||
TODO:
|
||||
need to figure out sign, size (using nlz), what else??
|
||||
bignum2_type *bn = gc_alloc_bignum2(data, 2);
|
||||
bn->num_digits = 2;
|
||||
bn->sign = 0;
|
||||
str_to_bignum(data, bn, str, str_end, radix);
|
||||
}
|
||||
|
||||
/* Write from digit character stream to bignum. Bignum does not need
|
||||
* to be initialised. Returns the bignum, or a fixnum. Assumes the
|
||||
* string contains only digits that fit within radix (checked by
|
||||
* string->number).
|
||||
*/
|
||||
//static C_regparm C_word
|
||||
object str_to_bignum(void *data, object bignum, char *str, char *str_end, int radix)
|
||||
static object str_to_bignum(void *data, object bignum, char *str, char *str_end, int radix)
|
||||
{
|
||||
int radix_shift, str_digit;
|
||||
uint32_t *digits = C_bignum_digits(bignum),
|
||||
|
|
Loading…
Add table
Reference in a new issue