jac3km4 / redscript

Compiler/decompiler toolkit for redscript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arithmetic operations possibly broken?

fre-sch opened this issue · comments

There's something weird going on with arithmetic operations. At first I tried something like this, because I noticed weird results in something I injected:

let a = 2.0;
let b = 3.0;
let c = 4.0;
let d = a * b + c; /* expect 10, not 14 */

Log("debug num: " + FloatToString(d));

However logs (in CET) showed neither 10.000000 or 14.000000, but 0.000000 instead.

Then I simplified it to:

let a: Float = 2.0;
let b: Float = 3.0;
let d: Float = a * b;
Log("debug num: " + FloatToString(d));

But it still logged 0.000000.

commented

I think this is because float constants emit the wrong instruction (f64 instead of f32) when the type is inferred to Float instead of Double.
I've pushed a fix on a branch:
https://github.com/jac3km4/redscript/tree/float-fix

Branch float-fix does enable arithmatic.