Commit 03356936 authored by twanvl's avatar twanvl

some fixes to ^ operator

parent ec70b27d
...@@ -403,10 +403,25 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP& ...@@ -403,10 +403,25 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
} }
break; break;
case I_POW: case I_POW:
if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { if (bt == SCRIPT_INT) {
a = to_script(pow((double)*a, (double)*b)); int bi = *b;
if (at == SCRIPT_DOUBLE) {
double aa = *a;
if (bi == 0) a = to_script(1);
else if (bi == 1) a = to_script(aa);
else if (bi == 2) a = to_script(aa * aa);
else if (bi == 3) a = to_script(aa * aa * aa);
else a = to_script(pow(aa,bi));
} else {
int aa = *a;
if (bi == 0) a = to_script(1);
else if (bi == 1) a = to_script(aa);
else if (bi == 2) a = to_script(aa * aa);
else if (bi == 3) a = to_script(aa * aa * aa);
else a = to_script(pow(aa,bi));
}
} else { } else {
a = to_script(pow((int)*a, (int)*b)); a = to_script(pow((double)*a, (double)*b));
} }
break; break;
case I_AND: OPERATOR_B(&&); case I_AND: OPERATOR_B(&&);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment