Closed ghost closed 7 years ago
In which targets is this reproduced? Can you add a PR with two commits: one enabling a test where is this reproduced (and fails in travis) and another commit disabling it so we can merge and fix it later? I can check it today or this weekend
Yes, i try reproduce in first step. Created ticket firstly, for bug naming =) maybe in next time need better name, not Issue244 =)))
BTW, haxe have impl already, need mapping http://api.haxe.org/Math.html#NEGATIVE_INFINITY
I make 100 test try understands why my app crach =) And finally i find it:
int i = (int) Float.NaN
@soywiz need your help, i make commit soon with new test. I understand first problem with string, but not understand how fix second.
java
2147483647
-2147483648
0
jtransc
0
0
-2147483648
Float to int conversions in haxe happens here: https://github.com/jtransc/jtransc/blob/bd0a45d3d39b88e8f4e35455bd4d356e33e2a04b/jtransc-rt/resources/hx/N.hx#L199
But is it a crash? Or just an undefined behaviour? Or that 0 happens to convert into a division by zero?
I can not catch in MSVC, only comment part of code and test =( Because reflection in project very hard, find too very hard. I think
return (value - min) / (max - min);
if default value will be +INF and -INF then in java / 2+INF
in jtransc / 0
Do you have the native crash report from android? Maybe the error says something relevant. Whether it is just an exception uncatched (stdout should note that), or a memory crash or division by 0 crash or things like that. Maybe something like this would work? Or logging via adb https://play.google.com/store/apps/details?id=com.nolanlawson.logcat&hl=es
We can try to test edge cases related with nans, infinites, divisions, and so on.
For example idiv, it is know to crash in some edge cases, that are covered here: https://github.com/jtransc/jtransc/blob/bd0a45d3d39b88e8f4e35455bd4d356e33e2a04b/jtransc-rt/resources/hx/N.hx#L217
But didn't know float operations caused that too.
Another step can be modify N.hx :: N.f2i
to add ifs to handle infinites like Java do
Ok, i try do it.
I have added support for %.2f
in formatter and unified (int)floatValue
, (int)doubleValue
.
By mistake I pushed it to master directly, now I have set the config so I cannot push to master directly.
https://github.com/jtransc/jtransc/commit/a522fd0ae61e0418b4e1be840fde804721294e34 https://github.com/jtransc/jtransc/commit/79fc7b04c55d3d68c9642bca3eb6a95c5ade40a3 https://github.com/jtransc/jtransc/commit/69310eed24a23b69442981506ed9b591c5c06a92
String.format("val=%.2f, normal=%.2f, min=%.2f, max=%.2f, ", getProgressValue(), getProgressNormal(), getProgressMin(), getProgressMax())
If any where returnFloat.NaN
always crash.I try make as in Android