\ bignum>float { bignum } { float } define-primitive
\ bignum>float make-foldable
-\ (string>float) { byte-array } { float } define-primitive
-\ (string>float) make-foldable
-
\ (float>string) { float } { byte-array } define-primitive
\ (float>string) make-foldable
{ "double>bits" "math" "primitive_double_bits" (( x -- n )) }
{ "float>bits" "math" "primitive_float_bits" (( x -- n )) }
{ "(float>string)" "math.parser.private" "primitive_float_to_str" (( n -- str )) }
- { "(string>float)" "math.parser.private" "primitive_str_to_float" (( str -- n/f )) }
{ "bignum*" "math.private" "primitive_bignum_multiply" (( x y -- z )) }
{ "bignum+" "math.private" "primitive_bignum_add" (( x y -- z )) }
{ "bignum-" "math.private" "primitive_bignum_subtract" (( x y -- z )) }
ctx->replace(allot_float(bignum_to_float(ctx->peek())));
}
-void factor_vm::primitive_str_to_float()
-{
- byte_array *bytes = untag_check<byte_array>(ctx->peek());
- cell capacity = array_capacity(bytes);
-
- char *c_str = (char *)(bytes + 1);
- char *end = c_str;
- double f = strtod(c_str,&end);
- if(end == c_str + capacity - 1)
- ctx->replace(allot_float(f));
- else
- ctx->replace(false_object);
-}
-
void factor_vm::primitive_float_to_str()
{
byte_array *array = allot_byte_array(33);
PRIMITIVE(size)
PRIMITIVE(sleep)
PRIMITIVE(special_object)
-PRIMITIVE(str_to_float)
PRIMITIVE(string)
PRIMITIVE(string_nth)
PRIMITIVE(strip_stack_traces)
DECLARE_PRIMITIVE(size)
DECLARE_PRIMITIVE(sleep)
DECLARE_PRIMITIVE(special_object)
-DECLARE_PRIMITIVE(str_to_float)
DECLARE_PRIMITIVE(string)
DECLARE_PRIMITIVE(string_nth)
DECLARE_PRIMITIVE(strip_stack_traces)
cell unbox_array_size_slow();
void primitive_fixnum_to_float();
void primitive_bignum_to_float();
- void primitive_str_to_float();
void primitive_float_to_str();
void primitive_float_eq();
void primitive_float_add();