ecma_bigint_get_digits_and_sign (ecma_value_t value, /**< BigInt value */
                                 uint64_t *digits_p, /**< [out] buffer for digits */
                                 uint32_t size, /**< buffer size in digits */
                                 bool *sign_p) /**< [out] sign of BigInt */
{
  JERRY_ASSERT (ecma_is_value_bigint (value));

  if (value == ECMA_BIGINT_ZERO)
  {
    if (sign_p != NULL)
    {
      *sign_p = false;
    }
    memset (digits_p, 0, size * sizeof (uint64_t));
    return;
  }

  ecma_extended_primitive_t *value_p = ecma_get_extended_primitive_from_value (value);

  if (sign_p != NULL)
  {
    *sign_p = (value_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN) != 0;
  }

  uint32_t bigint_size = ECMA_BIGINT_GET_SIZE (value_p);
  uint32_t copy_size = bigint_size / sizeof (uint64_t);

  if (copy_size > size)
  {
    copy_size = size;
  }

  const uint64_t *digits_end_p = digits_p + copy_size;
  ecma_bigint_digit_t *source_p = ECMA_BIGINT_GET_DIGITS (value_p, 0);

  while (digits_p < digits_end_p)
  {
    *digits_p++ = source_p[0] | (((uint64_t) source_p[1]) << (8 * sizeof (ecma_bigint_digit_t)));
    source_p += 2;
  }

  size -= copy_size;

  if (size == 0)
  {
    return;
  }

  if (ECMA_BIGINT_SIZE_IS_ODD (bigint_size))
  {
    *digits_p++ = source_p[0];
    size--;
  }

  if (size > 0)
  {
    memset (digits_p, 0, size * sizeof (uint64_t));
  }
} /* ecma_bigint_get_digits_and_sign */
ecma_bigint_get_digits_and_sign (ecma_value_t value,  
                                 uint64_t *digits_p,  
                                 uint32_t size,  
                                 bool *sign_p)  
{
  JERRY_ASSERT (ecma_is_value_bigint (value));

  if (value == ECMA_BIGINT_ZERO)
  {
    if (sign_p != NULL)
    {
      *sign_p = false;
    }
    memset (digits_p, 0, size * sizeof (uint64_t));
    return;
  }

  ecma_extended_primitive_t *value_p = ecma_get_extended_primitive_from_value (value);

  if (sign_p != NULL)
  {
    *sign_p = (value_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN) != 0;
  }

  uint32_t bigint_size = ECMA_BIGINT_GET_SIZE (value_p);
  uint32_t copy_size = bigint_size / sizeof (uint64_t);

  if (copy_size > size)
  {
    copy_size = size;
  }

  const uint64_t *digits_end_p = digits_p + copy_size;
  ecma_bigint_digit_t *source_p = ECMA_BIGINT_GET_DIGITS (value_p, 0);

  while (digits_p < digits_end_p)
  {
    *digits_p++ = source_p[0] | (((uint64_t) source_p[1]) << (8 * sizeof (ecma_bigint_digit_t)));
    source_p += 2;
  }

  size -= copy_size;

  if (size == 0)
  {
    return;
  }

  if (ECMA_BIGINT_SIZE_IS_ODD (bigint_size))
  {
    *digits_p++ = source_p[0];
    size--;
  }

  if (size > 0)
  {
    memset (digits_p, 0, size * sizeof (uint64_t));
  }
}  