You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "huberylee (via GitHub)" <gi...@apache.org> on 2023/10/31 08:39:54 UTC
Re: [PR] GH-35576: [C++] Make Decimal{128,256}::FromReal more accurate [arrow]
huberylee commented on code in PR #35997:
URL: https://github.com/apache/arrow/pull/35997#discussion_r1377227122
##########
cpp/src/arrow/util/decimal_test.cc:
##########
@@ -868,24 +867,29 @@ template <typename T>
class TestDecimalFromRealFloat : public ::testing::Test {
protected:
std::vector<FromFloatTestParam> GetValues() {
- return {// 2**63 + 2**40 (exactly representable in a float's 24 bits of precision)
- FromFloatTestParam{9.223373e+18f, 19, 0, "9223373136366403584"},
- FromFloatTestParam{-9.223373e+18f, 19, 0, "-9223373136366403584"},
- FromFloatTestParam{9.223373e+14f, 19, 4, "922337313636640.3584"},
- FromFloatTestParam{-9.223373e+14f, 19, 4, "-922337313636640.3584"},
- // 2**64 - 2**40 (exactly representable in a float)
- FromFloatTestParam{1.8446743e+19f, 20, 0, "18446742974197923840"},
- FromFloatTestParam{-1.8446743e+19f, 20, 0, "-18446742974197923840"},
- // 2**64 + 2**41 (exactly representable in a float)
- FromFloatTestParam{1.8446746e+19f, 20, 0, "18446746272732807168"},
- FromFloatTestParam{-1.8446746e+19f, 20, 0, "-18446746272732807168"},
- FromFloatTestParam{1.8446746e+15f, 20, 4, "1844674627273280.7168"},
- FromFloatTestParam{-1.8446746e+15f, 20, 4, "-1844674627273280.7168"},
- // Almost 10**38 (minus 2**103)
- FromFloatTestParam{9.999999e+37f, 38, 0,
- "99999986661652122824821048795547566080"},
- FromFloatTestParam{-9.999999e+37f, 38, 0,
- "-99999986661652122824821048795547566080"}};
+ return {
+ // -- Stress the 24 bits of precision of a float
+ // 2**63 + 2**40
+ FromFloatTestParam{9.223373e+18f, 19, 0, "9223373136366403584"},
Review Comment:
Hi, the expected return value of ``FromFloatTestParam{5.76460752e13f, 18, 4, "57646075230342.3488"}`` is ``57646073774080.0000``, which seems different from the original value, does that meet expectations?
##########
cpp/src/arrow/util/decimal_test.cc:
##########
@@ -868,24 +867,29 @@ template <typename T>
class TestDecimalFromRealFloat : public ::testing::Test {
protected:
std::vector<FromFloatTestParam> GetValues() {
- return {// 2**63 + 2**40 (exactly representable in a float's 24 bits of precision)
- FromFloatTestParam{9.223373e+18f, 19, 0, "9223373136366403584"},
- FromFloatTestParam{-9.223373e+18f, 19, 0, "-9223373136366403584"},
- FromFloatTestParam{9.223373e+14f, 19, 4, "922337313636640.3584"},
- FromFloatTestParam{-9.223373e+14f, 19, 4, "-922337313636640.3584"},
- // 2**64 - 2**40 (exactly representable in a float)
- FromFloatTestParam{1.8446743e+19f, 20, 0, "18446742974197923840"},
- FromFloatTestParam{-1.8446743e+19f, 20, 0, "-18446742974197923840"},
- // 2**64 + 2**41 (exactly representable in a float)
- FromFloatTestParam{1.8446746e+19f, 20, 0, "18446746272732807168"},
- FromFloatTestParam{-1.8446746e+19f, 20, 0, "-18446746272732807168"},
- FromFloatTestParam{1.8446746e+15f, 20, 4, "1844674627273280.7168"},
- FromFloatTestParam{-1.8446746e+15f, 20, 4, "-1844674627273280.7168"},
- // Almost 10**38 (minus 2**103)
- FromFloatTestParam{9.999999e+37f, 38, 0,
- "99999986661652122824821048795547566080"},
- FromFloatTestParam{-9.999999e+37f, 38, 0,
- "-99999986661652122824821048795547566080"}};
+ return {
+ // -- Stress the 24 bits of precision of a float
+ // 2**63 + 2**40
+ FromFloatTestParam{9.223373e+18f, 19, 0, "9223373136366403584"},
Review Comment:
Hi, the expected return value of ``FromFloatTestParam{5.76460752e13f, 18, 4, "57646075230342.3488"}`` is ``57646073774080.0000``, which seems different from the original value, does that meet expectations?
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org