MCPcopy Create free account
hub / github.com/apache/impala / MaxBitsRequiredAfterScaling

Function MaxBitsRequiredAfterScaling

be/src/runtime/decimal-value.inline.h:185–193  ·  view source on GitHub ↗

Returns the maximum possible number of bits required to represent num * 10^scale_by.

Source from the content-addressed store, hash-verified

183
184// Returns the maximum possible number of bits required to represent num * 10^scale_by.
185inline int MaxBitsRequiredAfterScaling(int128_t num, int scale_by) {
186 // TODO: We are doing a lot of these abs() operations on int128_t in many places in our
187 // decimal math code. It might make sense to do this upfront, then do the calculations
188 // in unsigned math and adjust the sign at the end.
189 int num_occupied = 128 - BitUtil::CountLeadingZeros<int128_t>(abs(num));
190 DCHECK_GE(scale_by, 0);
191 DCHECK_LE(scale_by, 76);
192 return num_occupied + MaxBitsRequiredIncreaseAfterScaling(scale_by);
193}
194
195// Returns the minimum number of leading zero x or y would have after one of them gets
196// scaled up to match the scale of the other one.

Callers 2

TestScaleByFunction · 0.85
DivideMethod · 0.85

Calls 2

absFunction · 0.85

Tested by 1

TestScaleByFunction · 0.68