cpp/src/arrow/util/basic_decimal.cc
/// Expands the given value into a big endian array of ints so that we can work on
/// it. The array will be converted to an absolute value and the was_negative
/// flag will be set appropriately. The array will remove leading zeros from
/// the value.
/// \param array a big endian array of length 4 to set with the value
/// \param was_negative a flag for whether the value was original negative
/// \result the output length of the array
Expands the given value into a big endian array of ints so that we can work on
it. The array will be converted to an absolute value and the was_negative
flag will be set appropriately. The array will remove leading zeros from
the value.
\param array a big endian array of length 4 to set with the value
\param was_negative a flag for whether the value was original negative
\result the output length of the array
Expands the given value into a big endian array of ints so that we can work on it . The array will be converted to an absolute value and the was_negative flag will be set appropriately . The array will remove leading zeros from the value . \ param array a big endian array of length 4 to set with the value \ param was_negative a flag for whether the value was original negative \ result the output length of the array
static int64_t FillInArray(const BasicDecimal128& value, uint32_t* array,
                           bool& was_negative) {
  BasicDecimal128 abs_value = BasicDecimal128::Abs(value);
  was_negative = value.high_bits() < 0;
  uint64_t high = static_cast<uint64_t>(abs_value.high_bits());
  uint64_t low = abs_value.low_bits();
  if (high != 0) {
    if (high > std::numeric_limits<uint32_t>::max()) {
      array[0] = static_cast<uint32_t>(high >> 32);
      array[1] = static_cast<uint32_t>(high);
      array[2] = static_cast<uint32_t>(low >> 32);
      array[3] = static_cast<uint32_t>(low);
      return 4;
    }
    array[0] = static_cast<uint32_t>(high);
    array[1] = static_cast<uint32_t>(low >> 32);
    array[2] = static_cast<uint32_t>(low);
    return 3;
  }
  if (low > std::numeric_limits<uint32_t>::max()) {
    array[0] = static_cast<uint32_t>(low >> 32);
    array[1] = static_cast<uint32_t>(low);
    return 2;
  }
  if (low == 0) {
    return 0;
  }
  array[0] = static_cast<uint32_t>(low);
  return 1;
}
static int64_t FillInArray ( const BasicDecimal128 & value , uint32_t * array , bool & was_negative ) { BasicDecimal128 abs_value = BasicDecimal128 :: Abs ( value ) ; was_negative = value . high_bits ( ) < 0 ; uint64_t high = static_cast < uint64_t > ( abs_value . high_bits ( ) ) ; uint64_t low = abs_value . low_bits ( ) ; if ( high != 0 ) { if ( high > std :: numeric_limits < uint32_t > :: max ( ) ) { array [ 0 ] = static_cast < uint32_t > ( high >> 32 ) ; array [ 1 ] = static_cast < uint32_t > ( high ) ; array [ 2 ] = static_cast < uint32_t > ( low >> 32 ) ; array [ 3 ] = static_cast < uint32_t > ( low ) ; return 4 ; } array [ 0 ] = static_cast < uint32_t > ( high ) ; array [ 1 ] = static_cast < uint32_t > ( low >> 32 ) ; array [ 2 ] = static_cast < uint32_t > ( low ) ; return 3 ; } if ( low > std :: numeric_limits < uint32_t > :: max ( ) ) { array [ 0 ] = static_cast < uint32_t > ( low >> 32 ) ; array [ 1 ] = static_cast < uint32_t > ( low ) ; return 2 ; } if ( low == 0 ) { return 0 ; } array [ 0 ] = static_cast < uint32_t > ( low ) ; return 1 ; }
Expands the given value into a big endian array of ints so that we can work on
it.
Expands the given value into a big endian array of ints so that we can work on it .
// FillInArray(std::array<uint64_t, N>& value_array, uint32_t* result_array) is not // called here as the following code has better performance, to avoid regression on // BasicDecimal128 Division.