fix: unexpected int happend
This commit is contained in:
@ -3,8 +3,6 @@
|
||||
inline ZYM::int2048 Any2Int(const std::any &value) {
|
||||
if (auto ptr = std::any_cast<ZYM::int2048>(&value))
|
||||
return *ptr;
|
||||
else if (auto ptr = std::any_cast<int>(&value))
|
||||
return std::move(ZYM::int2048(*ptr));
|
||||
else if (auto ptr = std::any_cast<double>(&value)) {
|
||||
std::stringstream buf;
|
||||
buf << std::fixed << std::setprecision(0) << *ptr;
|
||||
@ -176,7 +174,7 @@ std::any Add(std::any a, std::any b) {
|
||||
2)
|
||||
return (*ptr_a_string) + (*ptr_b_string);
|
||||
if ((ptr_a_bool != nullptr) && (ptr_b_bool != nullptr))
|
||||
return (*ptr_a_bool) + (*ptr_b_bool);
|
||||
return ZYM::int2048(int(*ptr_a_bool) + int(*ptr_b_bool));
|
||||
else if ((ptr_a_int2048 != nullptr) && (ptr_b_int2048 != nullptr))
|
||||
return (*ptr_a_int2048) + (*ptr_b_int2048);
|
||||
else if ((ptr_a_float != nullptr) && (ptr_b_float != nullptr))
|
||||
@ -195,7 +193,7 @@ std::any Sub(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_bool != nullptr) && (ptr_b_bool != nullptr))
|
||||
return (*ptr_a_bool) - (*ptr_b_bool);
|
||||
return ZYM::int2048(int(*ptr_a_bool) - int(*ptr_b_bool));
|
||||
else if ((ptr_a_int2048 != nullptr) && (ptr_b_int2048 != nullptr))
|
||||
return (*ptr_a_int2048) - (*ptr_b_int2048);
|
||||
else if ((ptr_a_float != nullptr) && (ptr_b_float != nullptr))
|
||||
@ -245,7 +243,7 @@ std::any Mul(std::any a, std::any b) {
|
||||
}
|
||||
}
|
||||
if ((ptr_a_bool != nullptr) && (ptr_b_bool != nullptr))
|
||||
return (*ptr_a_bool) * (*ptr_b_bool);
|
||||
return ZYM::int2048(int(*ptr_a_bool) * int(*ptr_b_bool));
|
||||
else if ((ptr_a_int2048 != nullptr) && (ptr_b_int2048 != nullptr))
|
||||
return (*ptr_a_int2048) * (*ptr_b_int2048);
|
||||
else if ((ptr_a_float != nullptr) && (ptr_b_float != nullptr))
|
||||
@ -294,7 +292,7 @@ std::any Divv(std::any a, std::any b) {
|
||||
} 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((*ptr_a_bool) / (*ptr_b_bool));
|
||||
return ZYM::int2048(int(*ptr_a_bool) / int(*ptr_b_bool));
|
||||
} else
|
||||
throw FatalError("Divv: Type Error", 48);
|
||||
}
|
||||
@ -321,7 +319,7 @@ std::any Mod(std::any a, std::any b) {
|
||||
} else if ((ptr_a_bool != nullptr) && (ptr_b_bool != nullptr)) {
|
||||
if ((*ptr_b_bool) == 0)
|
||||
throw InterpretException("Mod: divided by zero", 51);
|
||||
return ZYM::int2048((*ptr_a_bool) % (*ptr_b_bool));
|
||||
return ZYM::int2048(int(*ptr_a_bool) % int(*ptr_b_bool));
|
||||
} else
|
||||
throw FatalError("Mod: Type Error", 52);
|
||||
}
|
||||
|
Reference in New Issue
Block a user