mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Test printf - set more precisely printing floating point numbers (#2299)
We noticed such issue
expected: ^(K{C, -30304.8, -22634.574219, 24476.882812, E4929EC2,
1467582223, 96vL.+
got: ^(K{C, -30304.8, -22634.574219, 24476.882813, E4929EC2, 1467582223,
96vL.+
The input value is 24476.882812 and cannot be precisely represented as a
single-floating point, so compilers are allowed to round it to the
nearest representable value. In this case, the closest representable
value to 24476.882812 is 24476.8828125, which rounds to 24476.882813.
Even some versions of MSVC prints that value as 24476.882813 and some
24476.882812 : https://godbolt.org/z/5GhEf8KPT
The proposal is to set precisely how many number should be displayed to
avoid rounding.
This commit is contained in:
committed by
GitHub
parent
4e00778b93
commit
a429ce771e
@@ -247,7 +247,7 @@ cl_program makeMixedFormatPrintfProgram(cl_kernel* kernel_ptr,
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::array<std::vector<std::string>, 2> formats = {
|
std::array<std::vector<std::string>, 2> formats = {
|
||||||
{ { "%f", "%e", "%g", "%.13a", "%F", "%E", "%G", "%.13A" },
|
{ { "%.13f", "%e", "%g", "%.13a", "%.13F", "%E", "%G", "%.13A" },
|
||||||
{ "%d", "%i", "%u", "%x", "%o", "%X" } }
|
{ "%d", "%i", "%u", "%x", "%o", "%X" } }
|
||||||
};
|
};
|
||||||
std::vector<char> data_before(2 + genrand_int32(gMTdata) % 8);
|
std::vector<char> data_before(2 + genrand_int32(gMTdata) % 8);
|
||||||
|
|||||||
Reference in New Issue
Block a user