bridge/class-master/depend/pari/src/basemath/Fle.c
/* Return the signed binary representation (i.e. the Non-Adjacent Form
 * in base 2) of 0 <= a < 2^63 */
Return the signed binary representation  of 0 <= a < 2^63
Return the signed binary representation of 0 < = a < 2^63
static void
naf_repr(naf_t *x, ulong a)
{
  long t, i;
  ulong pbits, nbits;
  ulong c0 = 0, c1, a0;
  x->n = a;
  pbits = nbits = 0;
  for (i = 0; a; a >>= 1, ++i) {
    a0 = a & 1;
    c1 = (c0 + a0 + ((a & 2) >> 1)) >> 1;
    t = c0 + a0 - (c1 << 1);
    if (t < 0)
      nbits |= (1UL << i);
    else if (t > 0)
      pbits |= (1UL << i);
    c0 = c1;
  }
  c1 = c0 >> 1;
  t = c0 - (c1 << 1);
  if (t > 0 && i != BITS_IN_LONG) pbits |= (1UL << i);
  x->pbits = pbits;
  x->nbits = nbits;
  x->lnzb = t? i-2: i-3;
}
static void naf_repr ( naf_t * x , ulong a ) { long t , i ; ulong pbits , nbits ; ulong c0 = 0 , c1 , a0 ; x -> n = a ; pbits = nbits = 0 ; for ( i = 0 ; a ; a >>= 1 , ++ i ) { a0 = a & 1 ; c1 = ( c0 + a0 + ( ( a & 2 ) >> 1 ) ) >> 1 ; t = c0 + a0 - ( c1 << 1 ) ; if ( t < 0 ) nbits |= ( 1UL << i ) ; else if ( t > 0 ) pbits |= ( 1UL << i ) ; c0 = c1 ; } c1 = c0 >> 1 ; t = c0 - ( c1 << 1 ) ; if ( t > 0 && i != BITS_IN_LONG ) pbits |= ( 1UL << i ) ; x -> pbits = pbits ; x -> nbits = nbits ; x -> lnzb = t ? i - 2 : i - 3 ; }
Return the signed binary representation (i.e.
Return the signed binary representation ( i . e .
/* Note that we don't need to check whether t < 0, since a >= 0 implies
   * that this most significant signed bit must be non-negative. */ /* Note that expu returns the least nonzero bit in the argument,
   * like the bit-scan-rev instruction on Intel architectures. */ /* Using pbits here is justified by the fact that a >= 0, so the
   * most significant bit must be positive. */