fix: many bugs
This commit is contained in:
@ -278,9 +278,13 @@ std::any Div(std::any a, std::any b) {
|
||||
throw InterpretException(
|
||||
"Div: string operation not allowed in this situation", 43);
|
||||
double t_a = Any2Float(a);
|
||||
// std::cerr << t_a << std::endl;
|
||||
double t_b = Any2Float(b);
|
||||
// std::cerr << t_b << std::endl;
|
||||
// if (t_b == 0) throw InterpretException("Div: divided by zero", 44);
|
||||
t_a = t_a / t_b;
|
||||
// std::cerr << t_a << std::endl;
|
||||
if (t_a > -1e-8 && t_a < 0) t_a = 0;
|
||||
return t_a;
|
||||
}
|
||||
std::any Divv(std::any a, std::any b) {
|
||||
@ -296,17 +300,17 @@ std::any Divv(std::any a, std::any b) {
|
||||
double *ptr_a_float = std::any_cast<double>(&a);
|
||||
double *ptr_b_float = std::any_cast<double>(&b);
|
||||
if ((ptr_a_float != nullptr) && (ptr_b_float != nullptr)) {
|
||||
if ((*ptr_b_float) == 0)
|
||||
throw InterpretException("Divv: divided by zero", 45);
|
||||
return ZYM::int2048(std::floor((*ptr_a_float) / (*ptr_b_float)));
|
||||
// if ((*ptr_b_float) == 0)
|
||||
// throw InterpretException("Divv: divided by zero", 45);
|
||||
return ZYM::int2048(std::floor((*ptr_a_float) / (*ptr_b_float)));
|
||||
} else if ((ptr_a_int2048 != nullptr) && (ptr_b_int2048 != nullptr)) {
|
||||
if ((*ptr_b_int2048) == 0)
|
||||
throw InterpretException("Divv: divided by zero", 46);
|
||||
return (*ptr_a_int2048) / (*ptr_b_int2048);
|
||||
// throw InterpretException("Divv: divided by zero", 46);
|
||||
return (*ptr_a_int2048) / (*ptr_b_int2048);
|
||||
} else if ((ptr_a_bool != nullptr) && (ptr_b_bool != nullptr)) {
|
||||
if ((*ptr_b_bool) == 0)
|
||||
throw InterpretException("Divv: divided by zero", 47);
|
||||
return ZYM::int2048(int(*ptr_a_bool) / int(*ptr_b_bool));
|
||||
// throw InterpretException("Divv: divided by zero", 47);
|
||||
return ZYM::int2048(int(*ptr_a_bool) / int(*ptr_b_bool));
|
||||
} else
|
||||
throw FatalError("Divv: Type Error", 48);
|
||||
}
|
||||
|
Reference in New Issue
Block a user