ecma_bigint_unary (ecma_value_t value, /**< BigInt value */
                   ecma_bigint_unary_operation_type type) /**< type of unary operation */
{
  JERRY_ASSERT (ecma_is_value_bigint (value));

  if (value == ECMA_BIGINT_ZERO)
  {
    return ecma_bigint_create_from_digit (1, type != ECMA_BIGINT_UNARY_INCREASE);
  }

  ecma_extended_primitive_t *value_p = ecma_get_extended_primitive_from_value (value);

  uint32_t sign = (type != ECMA_BIGINT_UNARY_DECREASE) ? ECMA_BIGINT_SIGN : 0;

  if ((value_p->u.bigint_sign_and_size == (uint32_t) (sizeof (ecma_bigint_digit_t) | sign))
      && *ECMA_BIGINT_GET_DIGITS (value_p, 0) == 1)
  {
    return ECMA_BIGINT_ZERO;
  }

  ecma_extended_primitive_t *result_p;

  if ((value_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN) == (sign ^ ECMA_BIGINT_SIGN))
  {
    result_p = ecma_big_uint_increase (value_p);

    if (type != ECMA_BIGINT_UNARY_INCREASE && result_p != NULL)
    {
      result_p->u.bigint_sign_and_size |= ECMA_BIGINT_SIGN;
    }
  }
  else
  {
    result_p = ecma_big_uint_decrease (value_p);

    if (type == ECMA_BIGINT_UNARY_INCREASE && result_p != NULL)
    {
      result_p->u.bigint_sign_and_size |= ECMA_BIGINT_SIGN;
    }
  }

  if (JERRY_UNLIKELY (result_p == NULL))
  {
    return ecma_bigint_raise_memory_error ();
  }

  return ecma_make_extended_primitive_value (result_p, ECMA_TYPE_BIGINT);
} /* ecma_bigint_unary */
ecma_bigint_unary (ecma_value_t value,  
                   ecma_bigint_unary_operation_type type)  
{
  JERRY_ASSERT (ecma_is_value_bigint (value));

  if (value == ECMA_BIGINT_ZERO)
  {
    return ecma_bigint_create_from_digit (1, type != ECMA_BIGINT_UNARY_INCREASE);
  }

  ecma_extended_primitive_t *value_p = ecma_get_extended_primitive_from_value (value);

  uint32_t sign = (type != ECMA_BIGINT_UNARY_DECREASE) ? ECMA_BIGINT_SIGN : 0;

  if ((value_p->u.bigint_sign_and_size == (uint32_t) (sizeof (ecma_bigint_digit_t) | sign))
      && *ECMA_BIGINT_GET_DIGITS (value_p, 0) == 1)
  {
    return ECMA_BIGINT_ZERO;
  }

  ecma_extended_primitive_t *result_p;

  if ((value_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN) == (sign ^ ECMA_BIGINT_SIGN))
  {
    result_p = ecma_big_uint_increase (value_p);

    if (type != ECMA_BIGINT_UNARY_INCREASE && result_p != NULL)
    {
      result_p->u.bigint_sign_and_size |= ECMA_BIGINT_SIGN;
    }
  }
  else
  {
    result_p = ecma_big_uint_decrease (value_p);

    if (type == ECMA_BIGINT_UNARY_INCREASE && result_p != NULL)
    {
      result_p->u.bigint_sign_and_size |= ECMA_BIGINT_SIGN;
    }
  }

  if (JERRY_UNLIKELY (result_p == NULL))
  {
    return ecma_bigint_raise_memory_error ();
  }

  return ecma_make_extended_primitive_value (result_p, ECMA_TYPE_BIGINT);
}  