diff --git a/bin/ikarus b/bin/ikarus index 0aacf55..2f5522e 100755 Binary files a/bin/ikarus and b/bin/ikarus differ diff --git a/bin/ikarus-numerics.c b/bin/ikarus-numerics.c index e66ba2d..e04c951 100644 --- a/bin/ikarus-numerics.c +++ b/bin/ikarus-numerics.c @@ -1222,12 +1222,8 @@ ikrt_bnfxdivrem(ikp x, ikp y, ikpcb* pcb){ } - - - - ikp -ikrt_bntostring(ikp x, ikpcb* pcb){ +ikrt_bignum_to_bytevector(ikp x, ikpcb* pcb){ /* FIXME: avoid calling malloc, instead, use the heap pointer itself * as a buffer to hold the temporary data after ensuring that it has enough * space */ @@ -1258,9 +1254,9 @@ ikrt_bntostring(ikp x, ikpcb* pcb){ string_start++; bytes--; } - ikp str = ik_alloc(pcb, align(bytes + disp_string_data + (sign_bit?1:0))); - ref(str, 0) = fix(bytes + (sign_bit?1:0)); - ikp dest = str + disp_string_data; + ikp bv = ik_alloc(pcb, align(bytes + disp_bytevector_data + (sign_bit?1:0))); + ref(bv, 0) = fix(bytes + (sign_bit?1:0)); + ikp dest = bv + disp_bytevector_data; if(sign_bit){ *dest = '-'; dest++; @@ -1274,6 +1270,6 @@ ikrt_bntostring(ikp x, ikpcb* pcb){ dest[bytes] = 0; } free(mem); - return str + string_tag; + return bv + bytevector_tag; } diff --git a/src/ikarus.boot b/src/ikarus.boot index 0940cfb..7b2ef87 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/ikarus.numerics.ss b/src/ikarus.numerics.ss index 06e1f3f..1a6cd92 100644 --- a/src/ikarus.numerics.ss +++ b/src/ikarus.numerics.ss @@ -376,11 +376,16 @@ [(bignum? x) (even-bignum? x)] [else (error 'odd? "~s is not an integer" x)]))) + (define bignum->string + (lambda (x) + (utf8-bytevector->string + (foreign-call "ikrt_bignum_to_bytevector" x)))) + (define number->string (lambda (x) (cond [(fixnum? x) (fixnum->string x)] - [(bignum? x) (foreign-call "ikrt_bntostring" x)] + [(bignum? x) (bignum->string x)] [(flonum? x) (flonum->string x)] [else (error 'number->string "~s is not a number" x)])))