Question

The following code seems to corrupt Float.isNaN() logic on an old Android device. The device: LG-GT540 / Android2.3.7

[IMPORTANT UPDATE] The Android on board is SwiftDroid v2.0 ASIS (Based on CyanogenMod-7.1.0)

int a = 2;
float b = a;
Log.d("yo", "1, Float.isNaN=" + Float.isNaN(Float.NaN));
boolean test = (b == 2);
Log.d("yo", "2, Float.isNaN=" + Float.isNaN(Float.NaN));

This makes Float.isNaN(Float.NaN) to return "false" which is wrong.

Do you know why?

Is it a JVM error?

On all the devices we own, the code runs as expected:

1, Float.isNaN=true
2, Float.isNaN=true

But on an old Android from LG the second NaN test fails.

1, Float.isNaN=true
2, Float.isNaN=false

But why?!

Any ideas to workaround this case are very welcome!

Was it helpful?

Solution

According to a comment of wiz3kid this is a bug. Probably the error is related to modification SwiftDroid v2.0 ASIS (Based on CyanogenMod-7.1.0)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top