Why is Float.isNaN (Float.NaN) “false” on an old LG Android 2.3.7 phone?

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

[IMPORTANT UPDATE] Android on board - 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) return an false value.

Do you know why?

Is this a JVM bug?

On all the devices that we have, the code works as expected:

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

But on LG's old Android, the second NaN test fails.

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

But why?!

Any ideas for solving this case are very welcome!

+4
source share
1 answer

wiz3kid, . , SwiftDroid v2.0 ASIS ( CyanogenMod-7.1.0)

0

Source: https://habr.com/ru/post/1537328/


All Articles