bridge/class-master/depend/pari/src/basemath/gen1.c
/* set z = x+y and return 1 if x,y have the same sign
 * set z = x-y and return 0 otherwise */
set z = x+y and return 1 if x,y have the same sign
set z = x-y and return 0 otherwise
set z = x + y and return 1 if x y have the same sign set z = x - y and return 0 otherwise
static int
did_add(GEN x, GEN y, GEN *z)
{
  long tx = typ(x), ty = typ(y);
  if (tx == ty) switch(tx)
  {
    case t_INT: *z = addii(x,y); return 1;
    case t_FRAC: *z = addsub_frac(x,y,addii); return 1;
    case t_REAL:
      if (signe(x) == -signe(y))
      { *z = subrr(x,y); return 0; }
      else
      { *z = addrr(x,y); return 1; }
  }
  if (tx == t_REAL) switch(ty)
  {
    case t_INT:
      if (signe(x) == -signe(y))
      { *z = subri(x,y); return 0; }
      else
      { *z = addri(x,y); return 1; }
    case t_FRAC:
      if (signe(x) == -signe(gel(y,1)))
      { *z = gsub(x,y); return 0; }
      else
      { *z = gadd(x,y); return 1; }
  }
  else if (ty == t_REAL) switch(tx)
  {
    case t_INT:
      if (signe(x) == -signe(y))
      { *z = subir(x,y); return 0; }
      else
      { *z = addir(x,y); return 1; }
    case t_FRAC:
      if (signe(gel(x,1)) == -signe(y))
      { *z = gsub(x,y); return 0; }
      else
      { *z = gadd(x,y); return 1; }
  }
  *z = gadd(x,y); return 1;
}
static int did_add ( GEN x , GEN y , GEN * z ) { long tx = typ ( x ) , ty = typ ( y ) ; if ( tx == ty ) switch ( tx ) { case t_INT : * z = addii ( x , y ) ; return 1 ; case t_FRAC : * z = addsub_frac ( x , y , addii ) ; return 1 ; case t_REAL : if ( signe ( x ) == - signe ( y ) ) { * z = subrr ( x , y ) ; return 0 ; } else { * z = addrr ( x , y ) ; return 1 ; } } if ( tx == t_REAL ) switch ( ty ) { case t_INT : if ( signe ( x ) == - signe ( y ) ) { * z = subri ( x , y ) ; return 0 ; } else { * z = addri ( x , y ) ; return 1 ; } case t_FRAC : if ( signe ( x ) == - signe ( gel ( y , 1 ) ) ) { * z = gsub ( x , y ) ; return 0 ; } else { * z = gadd ( x , y ) ; return 1 ; } } else if ( ty == t_REAL ) switch ( tx ) { case t_INT : if ( signe ( x ) == - signe ( y ) ) { * z = subir ( x , y ) ; return 0 ; } else { * z = addir ( x , y ) ; return 1 ; } case t_FRAC : if ( signe ( gel ( x , 1 ) ) == - signe ( y ) ) { * z = gsub ( x , y ) ; return 0 ; } else { * z = gadd ( x , y ) ; return 1 ; } } * z = gadd ( x , y ) ; return 1 ; }
set z = x+y and return 1 if x,y have the same sign
 set z = x-y and return 0 otherwise
set z = x + y and return 1 if x y have the same sign set z = x - y and return 0 otherwise