Fix wchar.wcstold_hex_floats on arm64
This commit fixes wchar.wcstold_hex_floats on arm64. On AArch64 (ARM64), the `long double` type has 128 bits and is more precise then `double` type (64-bit). As a result, `1e100L` is slightly different from `static_cast<long double>(1e100)`. This commit fixes the regression by adding 'L' after the floating point literals. This should work because casting from a higher precision to lower precision won't lose any precisions. Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests \ --gtest-filter=wchar.wcstold_hex_floats Test: adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests Test: adb shell /data/nativetest64/bionic-unit-tests/bionic-unit-tests Change-Id: Ibd7b6a5d46c38338b4ca56838d9d272c710b32f6
This commit is contained in:
parent
f3b92f1485
commit
0288dbb739
|
@ -782,20 +782,20 @@ void TestSingleWcsToFloat(WcsToFloatFn<T> fn, const wchar_t* str,
|
|||
|
||||
template <typename T>
|
||||
void TestWcsToFloat(WcsToFloatFn<T> fn) {
|
||||
TestSingleWcsToFloat(fn, L"123", static_cast<T>(123.0), 3);
|
||||
TestSingleWcsToFloat(fn, L"123#", static_cast<T>(123.0), 3);
|
||||
TestSingleWcsToFloat(fn, L" 123 45", static_cast<T>(123.0), 6);
|
||||
TestSingleWcsToFloat(fn, L"9.0", static_cast<T>(9.0), 3);
|
||||
TestSingleWcsToFloat(fn, L"-9.0", static_cast<T>(-9.0), 4);
|
||||
TestSingleWcsToFloat(fn, L" \t\v\f\r\n9.0", static_cast<T>(9.0), 9);
|
||||
TestSingleWcsToFloat(fn, L"123", static_cast<T>(123.0L), 3);
|
||||
TestSingleWcsToFloat(fn, L"123#", static_cast<T>(123.0L), 3);
|
||||
TestSingleWcsToFloat(fn, L" 123 45", static_cast<T>(123.0L), 6);
|
||||
TestSingleWcsToFloat(fn, L"9.0", static_cast<T>(9.0L), 3);
|
||||
TestSingleWcsToFloat(fn, L"-9.0", static_cast<T>(-9.0L), 4);
|
||||
TestSingleWcsToFloat(fn, L" \t\v\f\r\n9.0", static_cast<T>(9.0L), 9);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TestWcsToFloatHexFloats(WcsToFloatFn<T> fn) {
|
||||
TestSingleWcsToFloat(fn, L"0.9e1", static_cast<T>(9.0), 5);
|
||||
TestSingleWcsToFloat(fn, L"0x1.2p3", static_cast<T>(9.0), 7);
|
||||
TestSingleWcsToFloat(fn, L"+1e+100", static_cast<T>(1e100), 7);
|
||||
TestSingleWcsToFloat(fn, L"0x10000.80", static_cast<T>(65536.50), 10);
|
||||
TestSingleWcsToFloat(fn, L"0.9e1", static_cast<T>(9.0L), 5);
|
||||
TestSingleWcsToFloat(fn, L"0x1.2p3", static_cast<T>(9.0L), 7);
|
||||
TestSingleWcsToFloat(fn, L"+1e+100", static_cast<T>(1e100L), 7);
|
||||
TestSingleWcsToFloat(fn, L"0x10000.80", static_cast<T>(65536.50L), 10);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
Loading…
Reference in New Issue