[
https://issues.apache.org/jira/browse/ARROW-1749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16239234#comment-16239234
]
ASF GitHub Bot commented on ARROW-1749:
---------------------------------------
cpcloud commented on a change in pull request #1282: ARROW-1749: [C++] Handle
range of Decimal128 values that require 39 digits to be displayed
URL: https://github.com/apache/arrow/pull/1282#discussion_r148941301
##########
File path: cpp/src/arrow/util/bit-util.h
##########
@@ -296,6 +297,25 @@ static inline int Log2(uint64_t x) {
return result;
}
+/// \brief Count the number of leading zeros in a 32 bit integer.
+static inline int64_t CountLeadingZeros(uint32_t value) {
+ DCHECK_NE(value, 0);
+#if defined(__clang__) || defined(__GNUC__)
+ return static_cast<int64_t>(__builtin_clz(value));
Review comment:
Interesting tidbit here is that `__builtin_clz` compiles to `31 - bit scan
reverse` on gcc and clang.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [C++] Handle range of Decimal128 values that require 39 digits to be displayed
> ------------------------------------------------------------------------------
>
> Key: ARROW-1749
> URL: https://issues.apache.org/jira/browse/ARROW-1749
> Project: Apache Arrow
> Issue Type: Bug
> Components: C++
> Affects Versions: 0.7.1
> Reporter: Phillip Cloud
> Assignee: Phillip Cloud
> Priority: Major
> Labels: pull-request-available
> Fix For: 0.8.0
>
>
> {{2 ** 127 - 1}} and {{-2 ** 127}} both require a 39th digit to be displayed
> as a decimal string.
> This means we do not have the ability to _display_ decimal values above {{10
> ** 38 - 1}} even though we have the ability to _store_ them.
> For reference, Impala returns {{NULL}} when trying to cast {{2 ** 127 - 1}}
> to {{DECIMAL(38, 0)}}.
> A few next steps are in order:
> # Explicitly test this behavior
> # Avoid crashing or displaying garbage when we cannot display a number that
> can be stored
> # Make a decision about whether we want to eventually support range of values
> from {{10 ** 38}} to {{2 ** 127 - 1}} positive and {{-2 ** 127}} to {{-10 **
> 38}} negative. This would require a larger integer type to hold the value
> just before being converted to a string.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)