bridge/class-master/depend/pari/src/basemath/gen2.c
/* returns the sign of x - y when it makes sense. 0 otherwise */
returns the sign of x - y when it makes sense. 0 otherwise
returns the sign of x - y when it makes sense . 0 otherwise
int
gcmp(GEN x, GEN y)
{
  long tx = typ(x), ty = typ(y);
  if (tx == ty) 
    switch(tx)
    {
      case t_INT:  return cmpii(x, y);
      case t_REAL: return cmprr(x, y);
      case t_FRAC: return cmpfrac(x, y);
      case t_QUAD: return cmpgen(x, y);
      case t_STR:  return cmp_str(GSTR(x), GSTR(y));
      case t_INFINITY:
      {
        long sx = inf_get_sign(x), sy = inf_get_sign(y);
        if (sx < sy) return -1;
        if (sx > sy) return 1;
        return 0;
      }
    }
  if (ty == t_INFINITY) return -inf_get_sign(y);
  switch(tx)
  {
    case t_INT:
      switch(ty)
      {
        case t_REAL: return cmpir(x, y);
        case t_FRAC: return cmpifrac(x, y);
        case t_QUAD: return cmpgen(x, y);
      }
      break;
    case t_REAL:
      switch(ty)
      {
        case t_INT:  return cmpri(x, y);
        case t_FRAC: return cmprfrac(x, y);
        case t_QUAD: return cmpgen(x, y);
      }
      break;
    case t_FRAC:
      switch(ty)
      {
        case t_INT:  return -cmpifrac(y, x);
        case t_REAL: return -cmprfrac(y, x);
        case t_QUAD: return cmpgen(x, y);
      }
      break;
    case t_QUAD:
      return cmpgen(x, y);
    case t_INFINITY: return inf_get_sign(x);
  }
  pari_err_TYPE2("comparison",x,y);
  return 0;
}
int gcmp ( GEN x , GEN y ) { long tx = typ ( x ) , ty = typ ( y ) ; if ( tx == ty ) switch ( tx ) { case t_INT : return cmpii ( x , y ) ; case t_REAL : return cmprr ( x , y ) ; case t_FRAC : return cmpfrac ( x , y ) ; case t_QUAD : return cmpgen ( x , y ) ; case t_STR : return cmp_str ( GSTR ( x ) , GSTR ( y ) ) ; case t_INFINITY : { long sx = inf_get_sign ( x ) , sy = inf_get_sign ( y ) ; if ( sx < sy ) return -1 ; if ( sx > sy ) return 1 ; return 0 ; } } if ( ty == t_INFINITY ) return - inf_get_sign ( y ) ; switch ( tx ) { case t_INT : switch ( ty ) { case t_REAL : return cmpir ( x , y ) ; case t_FRAC : return cmpifrac ( x , y ) ; case t_QUAD : return cmpgen ( x , y ) ; } break ; case t_REAL : switch ( ty ) { case t_INT : return cmpri ( x , y ) ; case t_FRAC : return cmprfrac ( x , y ) ; case t_QUAD : return cmpgen ( x , y ) ; } break ; case t_FRAC : switch ( ty ) { case t_INT : return - cmpifrac ( y , x ) ; case t_REAL : return - cmprfrac ( y , x ) ; case t_QUAD : return cmpgen ( x , y ) ; } break ; case t_QUAD : return cmpgen ( x , y ) ; case t_INFINITY : return inf_get_sign ( x ) ; } pari_err_TYPE2 ( " " , x , y ) ; return 0 ; }
returns the sign of x - y when it makes sense.
returns the sign of x - y when it makes sense .
/* generic case */ /*LCOV_EXCL_LINE*/