mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Issue #519 - fix bignum TODO's in Cyc_remainder
This commit is contained in:
parent
38276ffd46
commit
88fb4b909f
1 changed files with 11 additions and 15 deletions
20
runtime.c
20
runtime.c
|
@ -4660,11 +4660,9 @@ void Cyc_remainder(void *data, object cont, object num1, object num2)
|
||||||
Cyc_bignum_remainder(data, cont, num1, num2, rem);
|
Cyc_bignum_remainder(data, cont, num1, num2, rem);
|
||||||
}
|
}
|
||||||
else if (is_object_type(num2) && type_of(num2) == double_tag){
|
else if (is_object_type(num2) && type_of(num2) == double_tag){
|
||||||
// TODO: correct to convert bignum to double here
|
ii = mp_get_double(&bignum_value(num1));
|
||||||
j = ((double_type *)num2)->value;
|
jj = ((double_type *)num2)->value;
|
||||||
alloc_bignum(data, bn);
|
goto handledouble;
|
||||||
Cyc_int2bignum(obj_obj2int(j), &(bn->bn));
|
|
||||||
Cyc_bignum_remainder(data, cont, num1, bn, bn);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
goto typeerror;
|
goto typeerror;
|
||||||
|
@ -4676,11 +4674,9 @@ void Cyc_remainder(void *data, object cont, object num1, object num2)
|
||||||
goto handledouble;
|
goto handledouble;
|
||||||
}
|
}
|
||||||
else if (is_object_type(num2) && type_of(num2) == bignum_tag){
|
else if (is_object_type(num2) && type_of(num2) == bignum_tag){
|
||||||
// TODO: convert bignum to double here
|
ii = ((double_type *)num1)->value;
|
||||||
i = ((double_type *)num1)->value;
|
jj = mp_get_double(&bignum_value(num2));
|
||||||
alloc_bignum(data, bn);
|
goto handledouble;
|
||||||
Cyc_int2bignum(obj_obj2int(i), &(bn->bn));
|
|
||||||
Cyc_bignum_remainder(data, cont, bn, num2, bn);
|
|
||||||
}
|
}
|
||||||
else if (is_object_type(num2) && type_of(num2) == double_tag){
|
else if (is_object_type(num2) && type_of(num2) == double_tag){
|
||||||
ii = ((double_type *)num1)->value;
|
ii = ((double_type *)num1)->value;
|
||||||
|
@ -4697,11 +4693,11 @@ void Cyc_remainder(void *data, object cont, object num1, object num2)
|
||||||
result = obj_int2obj(i % j);
|
result = obj_int2obj(i % j);
|
||||||
return_closcall1(data, cont, result);
|
return_closcall1(data, cont, result);
|
||||||
handledouble:
|
handledouble:
|
||||||
{
|
{
|
||||||
if (jj == 0) { Cyc_rt_raise_msg(data, "Divide by zero"); }
|
if (jj == 0) { Cyc_rt_raise_msg(data, "Divide by zero"); }
|
||||||
make_double(dresult, fmod(ii, jj));
|
make_double(dresult, fmod(ii, jj));
|
||||||
return_closcall1(data, cont, &dresult);
|
return_closcall1(data, cont, &dresult);
|
||||||
}
|
}
|
||||||
typeerror:
|
typeerror:
|
||||||
{
|
{
|
||||||
make_string(s, "Bad argument type");
|
make_string(s, "Bad argument type");
|
||||||
|
|
Loading…
Add table
Reference in a new issue