bridge/class-master/depend/pari/src/basemath/rootpol.c
/* round a complex or real number x to an absolute value of 2^(-bit) */
round a complex or real number x to an absolute value of 2^(-bit)
round a complex or real number x to an absolute value of 2^ ( - bit )
static GEN
mygprec_absolute(GEN x, long bit)
{
  long e;
  GEN y;
  switch(typ(x))
  {
    case t_REAL:
      e = expo(x) + bit;
      return (e <= 0 || !signe(x))? real_0_bit(-bit): rtor(x, nbits2prec(e));
    case t_COMPLEX:
      if (gexpo(gel(x,2)) < -bit) return mygprec_absolute(gel(x,1),bit);
      y = cgetg(3,t_COMPLEX);
      gel(y,1) = mygprec_absolute(gel(x,1),bit);
      gel(y,2) = mygprec_absolute(gel(x,2),bit);
      return y;
    default: return x;
  }
}
static GEN mygprec_absolute ( GEN x , long bit ) { long e ; GEN y ; switch ( typ ( x ) ) { case t_REAL : e = expo ( x ) + bit ; return ( e <= 0 || ! signe ( x ) ) ? real_0_bit ( - bit ) : rtor ( x , nbits2prec ( e ) ) ; case t_COMPLEX : if ( gexpo ( gel ( x , 2 ) ) < - bit ) return mygprec_absolute ( gel ( x , 1 ) , bit ) ; y = cgetg ( 3 , t_COMPLEX ) ; gel ( y , 1 ) = mygprec_absolute ( gel ( x , 1 ) , bit ) ; gel ( y , 2 ) = mygprec_absolute ( gel ( x , 2 ) , bit ) ; return y ; default : return x ; } }
round a complex or real number x to an absolute value of 2^(-bit)
round a complex or real number x to an absolute value of 2^ ( - bit )