Double precision value computation errors on MediaTek processors

后端 未结 4 1808
时光取名叫无心
时光取名叫无心 2021-01-03 22:44

I\'ve found that one of my application posted on the market produces weird results on some phones. Upon investigation it turns out there is an issue with one function which

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 23:21

    Have anyone seen this bug before? Maybe this is a known issue?

    These show up on occasion on a couple of the Android mailing lists.

    I believe what you are seeing is the effect of (1) different CPUs and their handling of floating point values, and (2) storage sizes differences that lead to different roundings and truncations.

    For (1) use something like the following is used in native code:

    • _controlfp(_PC_24, _MCW_PC);
    • _controlfp(_RC_NEAR, _MCW_RC);

    For (2) use the common storage size, which is a float.

    There's sometimes another related problem in the native world: a float is passed to a function, but the value at the function is always 0.0f (rather than the non-0 value used to invoke the function). You can clear that with -mfloat-abi=softfp. See Hard-float and JNI.

    Unfortunately, you are at the mercy of the manufacturer when using their port of Android Java. Enjoy their tweaks, oversights and implementation bugs. At least its not corrupting your VM.

提交回复
热议问题