ecma_bigint_is_equal_to_number (ecma_value_t left_value, /**< left BigInt value */
                                ecma_number_t right_value) /**< right number value */
{
  JERRY_ASSERT (ecma_is_value_bigint (left_value));

  if (ecma_number_is_nan (right_value) || ecma_number_is_infinity (right_value))
  {
    return false;
  }

  if (left_value == ECMA_BIGINT_ZERO)
  {
    return right_value == 0;
  }

  ecma_extended_primitive_t *left_value_p = ecma_get_extended_primitive_from_value (left_value);

  /* Sign must be the same. */
  if (left_value_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN)
  {
    if (right_value > 0)
    {
      return false;
    }
  }
  else if (right_value < 0)
  {
    return false;
  }

  ecma_bigint_digit_t digits[3];
  uint32_t result = ecma_bigint_number_to_digits (right_value, digits);

  JERRY_ASSERT (ECMA_BIGINT_NUMBER_TO_DIGITS_GET_DIGITS (result) == 0
                || digits[ECMA_BIGINT_NUMBER_TO_DIGITS_GET_DIGITS (result) - 1] > 0);

  if (result & ECMA_BIGINT_NUMBER_TO_DIGITS_HAS_FRACTION)
  {
    return false;
  }

  uint32_t digits_size = ECMA_BIGINT_NUMBER_TO_DIGITS_GET_DIGITS_SIZE (result);
  uint32_t zero_size = ECMA_BIGINT_NUMBER_TO_DIGITS_GET_ZERO_SIZE (result);

  if (ECMA_BIGINT_GET_SIZE (left_value_p) != digits_size + zero_size)
  {
    return false;
  }

  ecma_bigint_digit_t *left_p = ECMA_BIGINT_GET_DIGITS (left_value_p, 0);
  ecma_bigint_digit_t *left_end_p = (ecma_bigint_digit_t *) (((uint8_t *) left_p) + zero_size);

  /* Check value bits first. */
  if (memcmp (left_end_p, digits, digits_size) != 0)
  {
    return false;
  }

  while (left_p < left_end_p)
  {
    if (*left_p++ != 0)
    {
      return false;
    }
  }

  return true;
} /* ecma_bigint_is_equal_to_number */
ecma_bigint_is_equal_to_number (ecma_value_t left_value,  
                                ecma_number_t right_value)  
{
  JERRY_ASSERT (ecma_is_value_bigint (left_value));

  if (ecma_number_is_nan (right_value) || ecma_number_is_infinity (right_value))
  {
    return false;
  }

  if (left_value == ECMA_BIGINT_ZERO)
  {
    return right_value == 0;
  }

  ecma_extended_primitive_t *left_value_p = ecma_get_extended_primitive_from_value (left_value);

   
  if (left_value_p->u.bigint_sign_and_size & ECMA_BIGINT_SIGN)
  {
    if (right_value > 0)
    {
      return false;
    }
  }
  else if (right_value < 0)
  {
    return false;
  }

  ecma_bigint_digit_t digits[3];
  uint32_t result = ecma_bigint_number_to_digits (right_value, digits);

  JERRY_ASSERT (ECMA_BIGINT_NUMBER_TO_DIGITS_GET_DIGITS (result) == 0
                || digits[ECMA_BIGINT_NUMBER_TO_DIGITS_GET_DIGITS (result) - 1] > 0);

  if (result & ECMA_BIGINT_NUMBER_TO_DIGITS_HAS_FRACTION)
  {
    return false;
  }

  uint32_t digits_size = ECMA_BIGINT_NUMBER_TO_DIGITS_GET_DIGITS_SIZE (result);
  uint32_t zero_size = ECMA_BIGINT_NUMBER_TO_DIGITS_GET_ZERO_SIZE (result);

  if (ECMA_BIGINT_GET_SIZE (left_value_p) != digits_size + zero_size)
  {
    return false;
  }

  ecma_bigint_digit_t *left_p = ECMA_BIGINT_GET_DIGITS (left_value_p, 0);
  ecma_bigint_digit_t *left_end_p = (ecma_bigint_digit_t *) (((uint8_t *) left_p) + zero_size);

   
  if (memcmp (left_end_p, digits, digits_size) != 0)
  {
    return false;
  }

  while (left_p < left_end_p)
  {
    if (*left_p++ != 0)
    {
      return false;
    }
  }

  return true;
}  