fix: bug in Div
This commit is contained in:
@ -210,8 +210,7 @@ std::any Mul(std::any a, std::any b) {
|
|||||||
std::string *ptr_b_string = std::any_cast<std::string>(&b);
|
std::string *ptr_b_string = std::any_cast<std::string>(&b);
|
||||||
if ((ptr_a_string != nullptr ? 1 : 0) + (ptr_b_string != nullptr ? 1 : 0) ==
|
if ((ptr_a_string != nullptr ? 1 : 0) + (ptr_b_string != nullptr ? 1 : 0) ==
|
||||||
2) {
|
2) {
|
||||||
throw InterpretException(
|
return std::string("");
|
||||||
"Mul: string operation not allowed in this situation", 40);
|
|
||||||
} else if ((ptr_a_string != nullptr ? 1 : 0) +
|
} else if ((ptr_a_string != nullptr ? 1 : 0) +
|
||||||
(ptr_b_string != nullptr ? 1 : 0) ==
|
(ptr_b_string != nullptr ? 1 : 0) ==
|
||||||
1) {
|
1) {
|
||||||
@ -273,9 +272,9 @@ std::any Div(std::any a, std::any b) {
|
|||||||
"Div: string operation not allowed in this situation", 43);
|
"Div: string operation not allowed in this situation", 43);
|
||||||
double t_a = Any2Float(a);
|
double t_a = Any2Float(a);
|
||||||
double t_b = Any2Float(b);
|
double t_b = Any2Float(b);
|
||||||
if (t_b == 0) throw InterpretException("Div: divided by zero", 44);
|
// if (t_b == 0) throw InterpretException("Div: divided by zero", 44);
|
||||||
t_a = t_a / t_b;
|
t_a = t_a / t_b;
|
||||||
return a;
|
return t_a;
|
||||||
}
|
}
|
||||||
std::any Divv(std::any a, std::any b) {
|
std::any Divv(std::any a, std::any b) {
|
||||||
if (std::any_cast<NoneType>(&a)) a = (bool)false;
|
if (std::any_cast<NoneType>(&a)) a = (bool)false;
|
||||||
|
Reference in New Issue
Block a user