waneck / testrepo

0 stars 0 forks source link

Issue 1825 - Floating point operations involving integer literals return wrong value in cpp target - haxe #1825

Closed waneck closed 11 years ago

waneck commented 11 years ago

[Google Issue #1825 : http://code.google.com/haxe/issues/detail?id=1825] by mlunar, at 2013-05-17T18:53:20.000Z What steps will reproduce the problem?

Build and run the attached code for both neko and cpp using: haxe -main Test -neko Test.n haxe -main Test -cpp cpp neko Test.n "cpp/Test"

What is the expected output? What do you see instead?

The expected result for all four test cases (neko A/B & cpp A/B) is the same (or at least within floating point accuracy limits).

Actual result is that when using integer literals for the cpp target (cpp A) in floating point operations, the cpp target seems to arrive at a different result than neko (neko A) or when converting integer literals to float literals (neko B & cpp B). This might be due to unwanted integer division or something similar.

In the example, the expected result would be: NEKO A INT x: 1.04312153938982 y: 0.203121730293194 z: 2.23148686455806 NEKO B FLOAT x: 1.04312153938982 y: 0.203121730293194 z: 2.23148686455806 CPP A INT x: 1.043121539 y: 0.2031217303 z: 2.231486865 CPP B FLOAT x: 1.043121539 y: 0.2031217303 z: 2.231486865

The actual result is: NEKO A INT x: 1.04312153938982 y: 0.203121730293194 z: 2.23148686455806 NEKO B FLOAT x: 1.04312153938982 y: 0.203121730293194 z: 2.23148686455806 CPP A INT x: 0.9450296792 y: 0.1107061725 z: 2.060032397 CPP B FLOAT x: 1.043121539 y: 0.2031217303 z: 2.231486865

My environment is Haxe 3.0.0 RC2, Neko 2.0.0, hxcpp 3.0.1 on Windows 7

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2013-05-17T19:33:02.000Z]

waneck commented 11 years ago

[comment from gameh...@gmail.com, published at 2013-05-20T04:45:14.000Z] The problem is: Dynamic + integer = integer

class Test { static function main() { var d:Dynamic = 1.5; trace(d+10); } }

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2013-05-20T12:26:20.000Z] Uhm, I thought we had fixed that already. Does it comes from CPP or from Haxe inference?

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2013-05-20T12:26:40.000Z]

waneck commented 11 years ago

[comment from gameh...@gmail.com, published at 2013-05-20T13:04:11.000Z] This was a problem with hxcpp - should nor be fixed.