mapleFU commented on issue #35606:
URL: https://github.com/apache/arrow/issues/35606#issuecomment-1553254203
```c++
// Common tests for Decimal128::FromReal(T, ...) and Decimal256::FromReal(T,
...)
template <typename T>
class TestDecimalFromReal : public ::testing::Test {
public:
using Decimal = typename T::first_type;
using Real = typename T::second_type;
using ParamType = FromRealTestParam<Real>;
void TestSuccess() {
const std::vector<ParamType> params{
// clang-format off
{0.0f, 1, 0, "0"},
{-0.0f, 1, 0, "0"},
{0.0f, 19, 4, "0.0000"},
{-0.0f, 19, 4, "0.0000"},
{123.0f, 7, 4, "123.0000"},
{-123.0f, 7, 4, "-123.0000"},
{456.78f, 7, 4, "456.7800"},
{-456.78f, 7, 4, "-456.7800"},
{456.784f, 5, 2, "456.78"},
{-456.784f, 5, 2, "-456.78"},
{456.786f, 5, 2, "456.79"},
{-456.786f, 5, 2, "-456.79"},
{999.99f, 5, 2, "999.99"},
{-999.99f, 5, 2, "-999.99"},
{123.0f, 19, 0, "123"},
{-123.0f, 19, 0, "-123"},
{123.4f, 19, 0, "123"},
{-123.4f, 19, 0, "-123"},
{123.6f, 19, 0, "124"},
{-123.6f, 19, 0, "-124"},
// 2**62
{4.611686e+18f, 19, 0, "4611686018427387904"},
{-4.611686e+18f, 19, 0, "-4611686018427387904"},
// 2**63
{9.223372e+18f, 19, 0, "9223372036854775808"},
{-9.223372e+18f, 19, 0, "-9223372036854775808"},
// 2**64
{1.8446744e+19f, 20, 0, "18446744073709551616"},
{-1.8446744e+19f, 20, 0, "-18446744073709551616"}
// clang-format on
};
for (const ParamType& param : params) {
CheckDecimalFromReal<Decimal>(param.real, param.precision, param.scale,
param.expected);
}
}
```
Here meets:
```c++
// 2**62
{4.611686e+18f, 19, 0, "4611686018427387904"},
{-4.611686e+18f, 19, 0, "-4611686018427387904"},
// 2**63
{9.223372e+18f, 19, 0, "9223372036854775808"},
{-9.223372e+18f, 19, 0, "-9223372036854775808"},
// 2**64
{1.8446744e+19f, 20, 0, "18446744073709551616"},
{-1.8446744e+19f, 20, 0, "-18446744073709551616"}
```
These values would be truncated on MinGW when type is `float`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]