* string->flonum now uses bytevectors as intermediate rep.

This commit is contained in:
Abdulaziz Ghuloum 2007-05-18 22:01:04 -04:00
parent 7ca0ddfa81
commit 691a42fe4e
4 changed files with 7 additions and 5 deletions

Binary file not shown.

View File

@ -5,16 +5,16 @@
#include <errno.h>
#include <math.h>
ikp
ikrt_string_to_flonum(ikp x, ikpcb* pcb){
double v = strtod(string_data(x), NULL);
ikrt_bytevector_to_flonum(ikp x, ikpcb* pcb){
double v = strtod((char*)x+off_bytevector_data, NULL);
ikp r = ik_alloc(pcb, flonum_size) + vector_tag;
ref(r, -vector_tag) = (ikp)flonum_tag;
flonum_data(r) = v;
return r;
}
ikp
ikrt_fl_plus(ikp x, ikp y,ikpcb* pcb){
ikp r = ik_alloc(pcb, flonum_size) + vector_tag;

Binary file not shown.

View File

@ -13,12 +13,14 @@
(define (flonum->string x)
(utf8-bytevector->string
(or (foreign-call "ikrt_flonum_to_bytevector" x
(make-bytevector 80 0))
($make-bytevector 80))
(error 'flonum->string "~s is not a flonum" x))))
(define (string->flonum x)
(cond
[(string? x) (foreign-call "ikrt_string_to_flonum" x)]
[(string? x)
(foreign-call "ikrt_bytevector_to_flonum"
(string->utf8-bytevector x))]
[else
(error 'string->flonum "~s is not a string" x)])))