Exemplo n.º 1
0
Arquivo: ec.hpp Projeto: herumi/mie
	static inline void sub(EcT& R, const EcT& P, const EcT& Q)
	{
#if 0
		if (P.inf_) { neg(R, Q); return; }
		if (Q.inf_) { R = P; return; }
		if (P.y == Q.y) { R.clear(); return; }
		Fp t;
		Fp::sub(t, Q.x, P.x);
		if (t.isZero()) {
			dbl(R, P, false);
			return;
		}
		Fp s;
		Fp::add(s, Q.y, P.y);
		Fp::neg(s, s);
		Fp::div(t, s, t);
		R.inf_ = false;
		Fp x3;
		Fp::mul(x3, t, t);
		x3 -= P.x;
		x3 -= Q.x;
		Fp::sub(s, P.x, x3);
		s *= t;
		Fp::sub(R.y, s, P.y);
		R.x = x3;
#else
		EcT nQ;
		neg(nQ, Q);
		add(R, P, nQ);
#endif
	}
Exemplo n.º 2
0
//==============================================================================
static void
interval_orientation4d(const double* x0,
                       const double* x1,
                       const double* x2,
                       const double* x3,
                       const double* x4,
                       double* lower,
                       double* upper)
{
   double lower1234, upper1234;
   interval_orientation3d(x1+1, x2+1, x3+1, x4+1, &lower1234, &upper1234);
   double lower0234, upper0234;
   interval_orientation3d(x0+1, x2+1, x3+1, x4+1, &lower0234, &upper0234);
   double lower0134, upper0134;
   interval_orientation3d(x0+1, x1+1, x3+1, x4+1, &lower0134, &upper0134);
   double lower0124, upper0124;
   interval_orientation3d(x0+1, x1+1, x2+1, x4+1, &lower0124, &upper0124);
   double lower0123, upper0123;
   interval_orientation3d(x0+1, x1+1, x2+1, x3+1, &lower0123, &upper0123);
   fesetround(FE_DOWNWARD);
   *lower= x0[0]*(x0[0]<0 ? upper1234 : lower1234)
     +neg(x1[0])*(x1[0]>0 ? upper0234 : lower0234)
          +x2[0]*(x2[0]<0 ? upper0134 : lower0134)
     +neg(x3[0])*(x3[0]>0 ? upper0124 : lower0124)
          +x4[0]*(x4[0]<0 ? upper0123 : lower0123);
   fesetround(FE_UPWARD);
   *upper= x0[0]*(x0[0]>0 ? upper1234 : lower1234)
     +neg(x1[0])*(x1[0]<0 ? upper0234 : lower0234)
          +x2[0]*(x2[0]>0 ? upper0134 : lower0134)
     +neg(x3[0])*(x3[0]<0 ? upper0124 : lower0124)
          +x4[0]*(x4[0]>0 ? upper0123 : lower0123);
   assert(*lower<=*upper);
}
Exemplo n.º 3
0
Foam::tmp<Foam::volScalarField> Foam::dragModels::GidaspowErgunWenYu::K
(
    const volScalarField& Ur
) const
{
    volScalarField alpha2(max(scalar(1) - alpha1_, scalar(1.0e-6)));
    volScalarField d(phase1_.d());
    volScalarField bp(pow(alpha2, -2.65));
    volScalarField Re(max(Ur*d/phase2_.nu(), scalar(1.0e-3)));

    volScalarField Cds
    (
        neg(Re - 1000)*(24.0*(1.0 + 0.15*pow(Re, 0.687))/Re)
      + pos(Re - 1000)*0.44
    );

    // Wen and Yu (1966)
    return
    (
        pos(alpha2 - 0.8)
       *(0.75*Cds*phase2_.rho()*Ur*bp/d)
      + neg(alpha2 - 0.8)
       *(
           150.0*alpha1_*phase2_.nu()*phase2_.rho()/(sqr(alpha2*d))
         + 1.75*phase2_.rho()*Ur/(alpha2*d)
        )
    );
}
Foam::tmp<Foam::volScalarField> Foam::GidaspowErgunWenYu::K
(
    const volScalarField& Ur
) const
{
    volScalarField beta(max(scalar(1) - alpha_, scalar(1.0e-6)));

    volScalarField bp(pow(beta, -2.65));
    volScalarField Re(max(Ur*phasea_.d()/phaseb_.nu(), scalar(1.0e-3)));

    volScalarField Cds
    (
        neg(Re - 1000)*(24.0*(1.0 + 0.15*pow(Re, 0.687))/Re)
      + pos(Re - 1000)*0.44
    );

    // Wen and Yu (1966)
    return
    (
        pos(beta - 0.8)
       *(0.75*Cds*phaseb_.rho()*Ur*bp/phasea_.d())
      + neg(beta - 0.8)
       *(
           150.0*alpha_*phaseb_.nu()*phaseb_.rho()/(sqr(beta*phasea_.d()))
         + 1.75*phaseb_.rho()*Ur/(beta*phasea_.d())
        )
    );
}
Foam::tmp<Foam::volVectorField>
Foam::wallLubricationModels::TomiyamaWallLubrication::Fi() const
{
    volVectorField Ur(pair_.Ur());

    const volVectorField& n(nWall());
    const volScalarField& y(yWall());

    volScalarField Eo(pair_.Eo());

    return
        (
            pos(Eo - 1.0)*neg(Eo - 5.0)*exp(-0.933*Eo + 0.179)
          + pos(Eo - 5.0)*neg(Eo - 33.0)*(0.00599*Eo - 0.0187)
          + pos(Eo - 33.0)*0.179
        )
       *0.5
       *pair_.dispersed().d()
       *(
            1/sqr(y)
          - 1/sqr(D_ - y)
        )
       *pair_.continuous().rho()
       *magSqr(Ur - (Ur & n)*n)
       *n;
}
Exemplo n.º 6
0
Arquivo: Int64.c Projeto: larusx/Int64
Int64 Int64_multi (Int64 left, Int64 right)
{
	int s = sign(right);
	Int64 bin;
	int i;
	if (s == 0)
	{
		left.hi = left.low = 0;
		return left;
	}
	else if (sign(left) == 0)
		return left;

	
	if (s < 0)
		right = neg(right);
	if (sign(left) < 0)
	{
		bin = neg(left);
		s = -s;
	}
	else
		bin = left;
	left.hi = left.low = 0;
	for (i = 0; i < 32; ++i, right.low >>= 1, bin = Int64_plus(bin, bin))
		if ((right.low & 1) != 0)
			left = Int64_plus(left, bin);
	for (i = 0; i < 32; ++i, right.hi >>= 1, bin = Int64_plus(bin, bin))
		if ((right.hi & 1) != 0)
			left = Int64_plus(left, bin);
	if (s < 0)
		left = neg(left);
	return left;
}
int main()
{
    std::cout << "neg(10) " << neg (10) << std::endl;
    std::cout << "neg(-0.1) " << neg (-0.1) << std::endl;
    std::cout << "neg(11000) " << neg (11000) << std::endl;
    return 0;
}
Exemplo n.º 8
0
int search_large(unsigned char *x, int m, unsigned char *y, int n) {
   unsigned int D, B[SIGMA], NEG0, NEG0m1;
   int i,j,k,count, first, p_len;

   p_len = m;
   m = 32;

   /* Preprocessing */
   BEGIN_PREPROCESSING
   for(i=0; i<SIGMA; i++) B[i] = neg(0);
   for(j=0; j<m; j++) B[x[j]] = B[x[j]] & neg((1<<j));
   NEG0 = neg(0);
   NEG0m1 = neg(0)<<(m-1);
   END_PREPROCESSING
   
   /* searching */
   BEGIN_SEARCHING
   count = 0;
   i = m-1;
   while( i < n ) {
      D = B[y[i]];
      while (D != NEG0) {
         if (D < NEG0m1) {
            k = 0; first=i-m+1;
            while(k<p_len && x[k]==y[first+k]) k++;
            if (k==p_len && i<n) count++;
         }
         i = i+1;
         D = (D<<1) | B[y[i]];
      }
      i=i+m;
   }
   END_SEARCHING
   return count;
}
Exemplo n.º 9
0
static bool isOK_setFormatForOneNumber(void) {
	OutputFormat format;
	nameString result[2] = { "%- 10.5lg", "% 10.5lg" };
	format.leftJustified = true;
	format.precision = 5;
	format.width = 10;
	for (short i = 0; i < 2; i++, neg(&format.leftJustified)) {
		SAVE_FUNCTION_CALLER();
		setFormatForOneNumber(&format);
		if (strcmp(result[i], format.oneNumber)) {
			PRINT_ERROR();
			return false;
		}
	}
	format.leftJustified = false;
	for (short i = 0; i < 2; i++, neg(&format.leftJustified)) {
		SAVE_FUNCTION_CALLER();
		setFormatForOneNumber(&format);
		if (!strcmp(result[i], format.oneNumber)) {
			PRINT_ERROR();
			return false;
		}
	}
	PRINT_OK();
	return true;
}
Exemplo n.º 10
0
BigInt BigInt::operator-=(const BigInt& second)
{
	neg();
	(*this) += second;
	neg();
	return *this;
}
Exemplo n.º 11
0
scfx_rep*
scfx_pow10::neg( int i )
{
    if( ! m_neg[i].is_normal() )
    {
	multiply( m_neg[i], *neg( i - 1 ), *neg( i - 1 ) );
    }
    return &m_neg[i];
}
Exemplo n.º 12
0
//==============================================================================
static double
simple_orientation2d(const double* x0,
                     const double* x1,
                     const double* x2)
{
   return x0[0]*x1[1] + neg(x0[0])*x2[1]
        + x1[0]*x2[1] + neg(x1[0])*x0[1]
        + x2[0]*x0[1] + neg(x2[0])*x1[1];
}
Exemplo n.º 13
0
literalt aig_prop_baset::lor(const bvt &bv)
{
  literalt literal=const_literal(true);

  // Introduces N-1 extra nodes for N bits
  // See convert_node for where this overhead is removed
  forall_literals(it, bv)
    literal=land(neg(*it), literal);

  return neg(literal);
}
Exemplo n.º 14
0
void aig_prop_baset::set_equal(literalt a, literalt b)
{
#ifdef USE_AIG_COMPACT
  // The compact encoding should reduce this
  l_set_to_true(lequal(a,b));

#else
  // we produce two constraints:
  // a|!b   !a|b

  l_set_to_true(lor(pos(a), neg(b)));
  l_set_to_true(lor(neg(a), pos(b)));
#endif
}
Exemplo n.º 15
0
char    *ft_addsubstr(char *a, char *b, int op)
{
    char    *abs_a;
    char    *abs_b;
    char    *ret;

    abs_a = absolute(a);
    abs_b = absolute(b);
	ret = NULL;
    if (op == 1)
    {
        ret = (neg(a) && neg(b)) ? operation(abs_a, abs_b, 1, 1) : ret;
        if ((neg(a) && !neg(b)) || (!neg(a) && neg(b)))
		{
        	if (ft_strcmp(abs_a, abs_b) >= 0)
            	ret = operation(abs_a, abs_b, 0, -1);
			else
            	ret = operation(abs_a, abs_b, 1, -1);
		}
        ret = (!neg(a) && !neg(b)) ? operation(abs_a, abs_b, 0, 1) : ret;
    }
	else
		ret = addsubstr_next(a, b, abs_a, abs_b);
    ft_strdel(&abs_a);
    ft_strdel(&abs_b);
    return (ret);
}
Exemplo n.º 16
0
literalt aig_prop_baset::lxor(literalt a, literalt b)
{
  if(a.is_false()) return b;
  if(b.is_false()) return a;
  if(a.is_true()) return neg(b);
  if(b.is_true()) return neg(a);

  if(a==b) return const_literal(false);
  if(a==neg(b)) return const_literal(true);

  // This produces up to three nodes!
  // See convert_node for where this overhead is removed
  return lor(land(a, neg(b)), land(neg(a), b));
}
void TestRefractionExtinction::testBase()
{
	RefractionExtinction refExt;
	Vec3d v(1.,0.,0.);
	float mag=4.f;
	refExt.forward(&v, &mag, 1);
	QVERIFY(mag>=4.);
	QVERIFY(v[2]>=0);


	Vec3d vert(0.,0.,1.);
	mag=2.0f;
	refExt.setExtinctionCoefficient(0.25);
	refExt.setTemperature(15.0);
	refExt.setPressure(1000.0);
	refExt.forward(&vert, &mag, 1);
	QVERIFY(mag==2.25);
	QVERIFY(vert[2]==1.0);

	Vec3d neg(std::sqrt(2.0),0.,std::sqrt(2.0));
	mag=2.0f;
	refExt.forward(&neg, &mag, 1);
	QVERIFY(mag==2.0);
	QVERIFY(neg[2]==std::sqrt(2.0));
}
Exemplo n.º 18
0
char enum_BBconflictInPath( branch *bru, char direction, block *bv, 
			    ushort *bb_seq, ushort len, block **bblist, int num_bb ) {

  int  cf, id, idx;
  char res;
  branch *br;

  // check for each branch conflicting with bru, whether it occurs in this path
  for( cf = 0; cf < bru->num_conflicts; cf++ ) {
    br = bru->conflicts[cf];

    id = enum_findBranch( br, bb_seq, len );
    if( id == -1 )
      continue;

    idx = getblock( bb_seq[id-1], bblist, 0, num_bb-1 );
    if( idx == -1 )
      continue;

    // direction taken by br to its successor in bb_seq
    res = detectDirection( br, bblist[idx] );
    if( ( direction == bru->jump_cond && bru->conflictdir_jump[cf] == res ) ||
        ( direction == neg( bru->jump_cond ) && bru->conflictdir_fall[cf] == res ) ) {

      // check cancellation of effect by assignment
      id = enum_effectCancelled( br, NULL, bb_seq, len, bblist, num_bb );

      if( id == -1 ) {
        return 1;
      }
    }
  }
  return 0;
}
Exemplo n.º 19
0
literalt cnft::land(const bvt &bv)
{
  if(bv.size()==0) return const_literal(true);
  if(bv.size()==1) return bv[0];
  if(bv.size()==2) return land(bv[0], bv[1]);

  forall_literals(it, bv)
    if(it->is_false())
      return *it;

  if(is_all(bv, const_literal(true)))
    return const_literal(true);

  bvt new_bv;

  eliminate_duplicates(bv, new_bv);

  bvt lits(2);
  literalt literal=new_variable();
  lits[1]=neg(literal);

  forall_literals(it, new_bv)
  {
    lits[0]=pos(*it);
    lcnf(lits);
  }
Exemplo n.º 20
0
void StrPrinter::bvisit(const Mul &x) {
    std::ostringstream o, o2;
    bool num = false;
    unsigned den = 0;
    std::map<RCP<const Basic>, RCP<const Basic>,
            RCPBasicKeyLessCmp> dict(x.dict_.begin(), x.dict_.end());

    if (eq(*(x.coef_), *minus_one)) {
        o << "-";
    } else if (neq(*(x.coef_), *one)) {
        o << parenthesizeLT(x.coef_, PrecedenceEnum::Mul) << "*";
        num = true;
    }

    for (auto &p: dict) {
        if ((is_a<Integer>(*p.second) &&
             rcp_static_cast<const Integer>(p.second)->is_negative()) ||
            (is_a<Rational>(*p.second) &&
             rcp_static_cast<const Rational>(p.second)->is_negative())) {
            if(eq(*(p.second), *minus_one)) {
                o2 << parenthesizeLT(p.first, PrecedenceEnum::Mul);
            } else {
                o2 << parenthesizeLE(p.first, PrecedenceEnum::Pow);
                o2 << "**";
                o2 << parenthesizeLE(neg(p.second), PrecedenceEnum::Pow);
            }
            o2 << "*";
            den++;
        } else {
            if(eq(*(p.second), *one)) {
                o << parenthesizeLT(p.first, PrecedenceEnum::Mul);
            } else {
                o << parenthesizeLE(p.first, PrecedenceEnum::Pow);
                o << "**";
                o << parenthesizeLE(p.second, PrecedenceEnum::Pow);
            }
            o << "*";
            num = true;
        }
    }

    if (!num) {
        o << "1*";
    }

    std::string s = o.str();
    s = s.substr(0, s.size() - 1);

    if (den != 0) {
        std::string s2 = o2.str();
        s2 = s2.substr(0, s2.size() - 1);
        if (den > 1) {
            str_ = s + "/(" + s2 + ")";
        } else {
            str_ = s + "/" + s2;
        }
    } else {
        str_ = s;
    }
}
Exemplo n.º 21
0
bool doc_manager::fold_neg(doc& dst) {
 start_over:
    for (unsigned i = 0; i < dst.neg().size(); ++i) {
        if (m.contains(dst.neg()[i], dst.pos()))
            return false;

        unsigned index;
        unsigned count = diff_by_012(dst.pos(), dst.neg()[i], index);
        if (count != 2) {
            if (count == 0) {
                return false;
            }
            else if (count == 3) {
                dst.neg().erase(tbvm(), i);
                --i;
            }
            else { // count == 1:
                m.set(dst.pos(), index, neg(dst.neg()[i][index]));
                dst.neg().intersect(tbvm(), dst.pos());
                goto start_over;
            }
        }
    }
    SASSERT(well_formed(dst));
    return true;
}
Exemplo n.º 22
0
int mainProfileReflect(int argc, char* argv[]) {
  if ( argc != 3 ) {
    printf("Usage: %s inGrid externalForce\n", argv[0]);
    return 0;
  }

  double externalForce = strtod(argv[2], NULL);

  char outNeg[256];
  char outPos[256];
  sprintf(outNeg, "%s.neg.dat", argv[1]);
  sprintf(outPos, "%s.pos.dat", argv[1]);
  
  Grid pos(argv[1]);
  Grid neg(pos);

  Vector3 force(0.0, 0.0, -externalForce);
  double v0;

  pos.addGradient(force);
  v0 = pos.getValue(0);
  pos.shift(-v0);
    

  neg.flipZ();
  neg.addGradient(force);
  v0 = pos.getValue(0);
  neg.shift(-v0);
  
  pos.averageProfileZBoltzmann(outPos);
  neg.averageProfileZBoltzmann(outNeg);
}
/* task that renders a single screen tile */
Vec3fa renderPixelStandard(float x, float y, const ISPCCamera& camera, RayStats& stats)
{
  /* initialize ray */
  Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf);

  /* intersect ray with scene */
  RTCIntersectContext context;
  rtcInitIntersectContext(&context);
  rtcIntersect1(g_scene,&context,RTCRayHit_(ray));
  RayStats_addRay(stats);

  /* shade pixels */
  Vec3fa color = Vec3fa(0.0f);
  if (ray.geomID != RTC_INVALID_GEOMETRY_ID)
  {
    Vec3fa diffuse = colors[ray.geomID];
    color = color + diffuse*0.1f;
    Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1));

    /* initialize shadow ray */
    Ray shadow(ray.org + ray.tfar*ray.dir, neg(lightDir), 0.001f, inf);

    /* trace shadow ray */
    rtcOccluded1(g_scene,&context,RTCRay_(shadow));
    RayStats_addShadowRay(stats);

    /* add light contribution */
    if (shadow.tfar >= 0.0f)
      color = color + diffuse*clamp(-dot(lightDir,normalize(ray.Ng)),0.0f,1.0f);
  }
  return color;
}
tmp<volScalarField> SpalartAllmarasIDDES::dTilda(const volScalarField& S) const
{
    volScalarField alpha = this->alpha();
    volScalarField expTerm = exp(sqr(alpha));

    volScalarField fHill =
        2*(pos(alpha)*pow(expTerm, -11.09) + neg(alpha)*pow(expTerm, -9.0));

    volScalarField fStep = min(2*pow(expTerm, -9.0), scalar(1));
    volScalarField fHyb = max(1 - fd(S), fStep);
    volScalarField fAmp = 1 - max(ft(S), fl(S));
    volScalarField fRestore = max(fHill - 1, scalar(0))*fAmp;

    // IGNORING ft2 terms
    volScalarField Psi = sqrt
    (
        min
        (
            scalar(100),
            (1 - Cb1_/(Cw1_*sqr(kappa_)*fwStar_)*fv2())/max(SMALL, fv1())
        )
    );

    return max
    (
        dimensionedScalar("SMALL", dimLength, SMALL),
        fHyb*(1 + fRestore*Psi)*y_
      + (1 - fHyb)*CDES_*Psi*delta()
    );
}
Exemplo n.º 25
0
static int read_raw(const PIXF_Info *info, void *imgbytes, size_t hsize)
{
	unsigned char *iptr = (unsigned char *)imgbytes;
	size_t        i, n;

	for (i = 0; i < info->height; i++) {
		n = fread(iptr, 1, hsize, info->f);

		if (n < hsize) {
			#ifdef PIXF_ENABLE_VERBOSE
				if (pixf_verbose)
					fprintf(stderr, "%s: unexpected EOF during reading of image data (expected %lu bytes, read %lu)\n",
						__func__, (unsigned long)hsize, (unsigned long)n);
			#endif
			return PIXF_ERR_READ;
		}

		/* if we are running on little-endian machine and sample size is
		more than 8 bits (aligned to 16 bits), swap bytes */
		#if __BYTE_ORDER==__LITTLE_ENDIAN
			if (info->bps>8) swap_b(iptr,hsize);
		#endif

		if (info->bpp == 1) neg((void *)iptr,hsize);

		iptr += hsize;
	}

	return PIXF_ERR_OK;
}
Exemplo n.º 26
0
Arquivo: calculus.c Projeto: cardz/uva
int count_negs(char *input, int *start, const int mode) {
  int negs = 0;
  int last_sign = POS;
  while (input[*start] != 0) {
    if (input[*start] == '(') {
      (*start)++;
      negs += count_negs(input, start, mode);
    }
    if (input[*start] == '-') {
      if (input[*start + 1] == '(') {
        *start = *start + 2;
        negs += count_negs(input, start, mode ^ 1);
        continue;
      }
      last_sign = NEG;
      (*start)++;
    }
    if (input[*start] == '+') {
      last_sign = POS;
      (*start)++;
    }
    if (input[*start] == 'x') {
      negs += neg(last_sign, mode);
      (*start)++;
    } 
    if (input[*start] == ')') {
      (*start)++;
      return negs;
    }
  }
  
  return negs;
}
Exemplo n.º 27
0
int detectDirection( branch *bru, block *bv ) {

  if( bru->bb->outgoing[1] == bv->bbid )
    return bru->jump_cond;
  else
    return neg( bru->jump_cond );

  /*
  char  *jumpdest;
  instr *insn;

  // If bru's jump dest. == start address of bv, 
  // then direction( bru, bv ) == bru's jump condition, otherwise the negation.

  insn = bru->bb->instrlist[ bru->bb->num_instr - 1 ];
  jumpdest = getJumpDest( insn );

  // printf( "dest: %s jumpdest: %s jumpdir: %d\n", bv->instrlist[0]->addr, jumpdest, jumpdir );

  if( jumpdest == NULL )
     return NA;

  if( strcmp( bv->instrlist[0]->addr, jumpdest ) == 0 )
    return bru->jump_cond;
  else
    return neg( bru->jump_cond );
  */
}
Exemplo n.º 28
0
static zword find_word(zword dictionarytable, const char *word, int length)
{
  zbyte zsciibuffer[12];
  int entry_length, word_length;
  int num_entries;
  void *p;

  entry_length = LOBYTE(dictionarytable);
  dictionarytable++;
  num_entries = LOWORD(dictionarytable);
  dictionarytable+=ZWORD_SIZE;

  if(zversion <= 3)
    word_length = 4;
  else
    word_length = 6;

  encodezscii(zsciibuffer, word_length, word_length, word, length);

  dictentry_len = word_length;
  
  if(is_neg(num_entries)) {  /* Unordered dictionary */
    num_entries = neg(num_entries);
    p = n_lfind(zsciibuffer, z_memory + dictionarytable, &num_entries,
		entry_length, cmpdictentry);
  } else {                   /* Ordered dictionary */
    p = n_bsearch(zsciibuffer, z_memory + dictionarytable, num_entries,
		  entry_length, cmpdictentry);
  }
  if(p)
    return ((zbyte *) p) - z_memory;

  return 0;
}
Exemplo n.º 29
0
void mpq_manager<SYNCH>::display_decimal(std::ostream & out, mpq const & a, unsigned prec) {
    mpz n1, d1, v1;
    get_numerator(a, n1);
    get_denominator(a, d1);
    if (is_neg(a)) {
        out << "-";
        neg(n1);
    }
    mpz ten(10);
    div(n1, d1, v1);
    display(out, v1);
    rem(n1, d1, n1);
    if (is_zero(n1))
        goto end; // number is an integer
    out << ".";
    for (unsigned i = 0; i < prec; i++) {
        mul(n1, ten, n1);
        div(n1, d1, v1);
        SASSERT(lt(v1, ten));
        display(out, v1);
        rem(n1, d1, n1);
        if (is_zero(n1))
            goto end; // number is precise
    }
    out << "?";
 end:
    del(ten); del(n1); del(d1); del(v1);
}
Exemplo n.º 30
0
char BBconflictInPath( branch *bru, char direction, block *bv, path *pv, block **bblist, int num_bb )
{
  int  cf, id;
  char res;
  branch *br;

  // check for each branch conflicting with bru, whether it occurs in this path
  for( cf = 0; cf < bru->num_conflicts; cf++ ) {
    br = bru->conflicts[cf];

    id = findBranch( br, pv->branch_eff, pv->branch_len );
    if( id == -1 )
      continue;

    res = pv->branch_dir[id];
    if( ( direction == bru->jump_cond && bru->conflictdir_jump[cf] == res ) ||
        ( direction == neg( bru->jump_cond ) && bru->conflictdir_fall[cf] == res ) ) {

      // check cancellation of effect by assignment
      id = effectCancelled( br, NULL, pv, bblist, num_bb );

      if( id == -1 ) {
        return 1;
      }
    }
  }
  return 0;
}