Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.49k stars 174 forks source link

Comparing FastFloats and floats on static targets with dynamic types doesn't work #1237

Closed MoritzBrueckner closed 4 years ago

MoritzBrueckner commented 4 years ago

Hi Robert,

there is a bug with comparing FastFloats and regular floats on static targets if they are stored in Dynamic type variables. I'm not sure if it can be fixed easily or if it should be handled by the programmer (= avoiding the Dynamic type in those cases).

Minimal example code, tested on Krom and Windows C target:

var a: kha.FastFloat = 4.123;
var b: Float = 4.120;

// Without those two lines, both C and Krom targets would print 'true'
var aD: Dynamic = a;
var bD: Dynamic = b;

// Krom: true, C: false
trace(aD >= bD);

For more details see https://github.com/armory3d/armory/issues/1814. It doesn't look like a Windows issue, it happens on the native Android target as well.

Also, casting FastFloat values back to floats does not always work on static targets, but I wasn't able to find a minimal reproducible example yet. The error message is Unsupported type value Single when compiling .hx code like v1 = cast(v1, Float); (v1 is a dynamic variable that holds a FastFloat).

Thanks!

RobDangerous commented 4 years ago

Well, that's not nice. But FastFloat is just a typedef, name aside it's not a special Kha thing. You should report that to the Haxe peeps.