您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ to_double函数代码示例

51自学网 2021-06-03 08:53:55
  C++
这篇教程C++ to_double函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中to_double函数的典型用法代码示例。如果您正苦于以下问题:C++ to_double函数的具体用法?C++ to_double怎么用?C++ to_double使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了to_double函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pop

void OperandStack::dcmpl(){    Operand op1H, op1L, op2H, op2L;		op2L = pop();	op2H = pop();	op1L = pop();	op1H = pop();		if( (op1H.type != TYPE_DOUBLE) || (op2H.type != TYPE_DOUBLE) ) {		printf("Error type not double: :op_stack.dcmpl/n");        exit(0);	}	double val1, val2;		val1 = to_double(op1H.bytes, op1L.bytes);	val2 = to_double(op2H.bytes, op2L.bytes);		if(isnan(val1) || isnan(val2)) {		iconst(-1);		return;	}		if(val1 == val2)		iconst(0);	else if(val1 > val2)		iconst(1);	else if(val1 < val2)		iconst(-1);}
开发者ID:Gabrielcarvfer,项目名称:SB2014JVM,代码行数:29,


示例2: split

bool mod_base::checkRange(std::string range, double &val, int *flag){	//take range std::string of form:	// {dlow,dhi} 	// where {} can be replaced by ( ), [ ], ( ], [ )	//parse the std::string	vector<std::string> t1 = split(range, ",");	if(t1.size()<2) return true;	std::string lop, rop, ops, ls, rs;	ls = t1.at(0);	rs = t1.at(1);	lop = ls.at(0);	rop = rs.at(rs.size()-1);	//Convert range values to doubles	double lval, rval;	to_double(ls.erase(0,1), &lval);	to_double(rs.erase(rs.size()-1,1), &rval);	//flags for information to return	int tflag=-1;	//return the type of range applied (i.e. less than, greater than | less than or equal to, greater than, etc)	bool retflag=false;	//Is the boundary satisfied?	ops = lop+rop;	if(ops == " "){return true;}	//no info, don't check	else if(ops == "()"){if(val > lval && val < rval) {retflag = true; tflag=1;}}	else if(ops == "[)"){if(val >= lval && val < rval) {retflag = true; tflag=2;}}	else if(ops == "(]"){if(val > lval && val <= rval) {retflag = true; tflag=3;}}	else if(ops == "[]"){if(val >= lval && val <= rval) {retflag = true; tflag=4;}}	else{retflag = true;}	if(flag != NULL) *flag = tflag;	return retflag;	//boundary not satisfied by any previous consideration}
开发者ID:gtqite,项目名称:ssc,代码行数:35,


示例3: ofs

void VACExtension::printTightMatrix(){    ofstream ofs("problem.dat");    Cost Top = wcsp->getUb();    for (unsigned int i = 0; i < wcsp->numberOfVariables(); i++) {        for (unsigned int j = 0; j < wcsp->numberOfVariables(); j++) {            if (i != j) {                EnumeratedVariable *x =                        (EnumeratedVariable *) wcsp->getVar(i);                EnumeratedVariable *y =                        (EnumeratedVariable *) wcsp->getVar(j);                Constraint *bctr = x->getConstr(y);                double t = 0;                if (bctr)                    t = bctr->getTightness();                if (t > to_double(Top))                    t = to_double(Top);                t = t * 256.0 / to_double(Top);                ofs << t << " ";            } else                ofs << 0 << " ";        }        ofs << endl;    }}
开发者ID:eomahony,项目名称:Numberjack,代码行数:26,


示例4: run_delta_double_bench

void run_delta_double_bench(struct optics_bench *b, void *data, size_t id, size_t n){    (void) data, (void) id, (void) n;    optics_bench_start(b);    for (size_t i = 0; i < n; ++i) {        double a;        {            struct timespec ts;            clock_monotonic_ptr(&ts);            a = to_double(&ts);        }        double b;        {            struct timespec ts;            clock_monotonic_ptr(&ts);            b = to_double(&ts);        }        double diff = b - a;        optics_no_opt_val(diff);    }}
开发者ID:RAttab,项目名称:optics,代码行数:25,


示例5: assert

int XMIResource::loadPoint(xmlTextReaderPtr reader, const model::BaseObject& o){    assert(o.kind() == LINK);    std::vector<double> points;    controller.getObjectProperty(o.id(), o.kind(), CONTROL_POINTS, points);    // iterate on attributes    for (int rc = xmlTextReaderMoveToFirstAttribute(reader); rc > 0; rc = xmlTextReaderMoveToNextAttribute(reader))    {        auto found = std::find(constXcosNames.begin(), constXcosNames.end(), xmlTextReaderConstName(reader));        enum xcosNames current = static_cast<enum xcosNames>(std::distance(constXcosNames.begin(), found));        switch (current)        {            case e_x:                points.push_back(to_double(xmlTextReaderConstValue(reader)));                break;            case e_y:                points.push_back(to_double(xmlTextReaderConstValue(reader)));                break;            default:                // ignore other parameters                // TODO: Does other metamodels might be managed there ?                break;        }    }    controller.setObjectProperty(o.id(), o.kind(), CONTROL_POINTS, points);    return 1;}
开发者ID:ScilabOrg,项目名称:scilab,代码行数:30,


示例6: hash_value

 std::size_t hash_value(const CGAL::Point_2<Kernel>& point) {   std::size_t seed = 0;   boost::hash_combine(seed, to_double(point.x()));   boost::hash_combine(seed, to_double(point.y()));   return seed; }
开发者ID:SoumyajitG,项目名称:VolRoverN,代码行数:7,


示例7: trunc_to_int

Color Texture4D::getNearest(double dx, double dy, double dz, double dw) const {    if (dx < 0.0)        dx = 0.0;    if (dx > 1.0)        dx = 1.0;    if (dy < 0.0)        dy = 0.0;    if (dy > 1.0)        dy = 1.0;    if (dz < 0.0)        dz = 0.0;    if (dz > 1.0)        dz = 1.0;    if (dw < 0.0)        dw = 0.0;    if (dw > 1.0)        dw = 1.0;    int ix = trunc_to_int(dx * to_double(this->xsize - 1));    int iy = trunc_to_int(dy * to_double(this->ysize - 1));    int iz = trunc_to_int(dz * to_double(this->zsize - 1));    int iw = trunc_to_int(dw * to_double(this->wsize - 1));    assert(ix >= 0 && ix < this->xsize);    assert(iy >= 0 && iy < this->ysize);    assert(iz >= 0 && iz < this->zsize);    assert(iw >= 0 && iw < this->wsize);    return this        ->data[iw * this->xsize * this->ysize * this->zsize + iz * this->xsize * this->ysize + iy * this->xsize + ix];}
开发者ID:thunderk,项目名称:paysages3d,代码行数:31,


示例8: to_double

double TerrainDefinition::getGridHeight(int x, int z, bool with_painting) {    double h;    if (!with_painting || !has_painting || !height_map->getGridValue(x, z, &h)) {        h = _height_noise->get2DTotal(to_double(x), to_double(z));    }    return h;}
开发者ID:jordonwu,项目名称:paysages3d,代码行数:9,


示例9: math_atan2

static void math_atan2(LVGActionCtx *ctx, ASClass *cls, uint8_t *a, uint32_t nargs){    ASVal *se_a = &ctx->stack[ctx->stack_ptr];    ASVal *se_b = se_a + 1;    ctx->stack_ptr++;    double va = to_double(ctx, se_a);    double vb = to_double(ctx, se_b);    ASVal *res = &ctx->stack[ctx->stack_ptr];    SET_DOUBLE(res, atan2(va, vb));}
开发者ID:lieff,项目名称:lvg,代码行数:10,


示例10: convert_to_stock

struct stock convert_to_stock(struct html_table *table){    struct stock _stock = {0};    _stock.sequence = (unsigned int)atoi(table->sequence);    memcpy(_stock.exchange, table->exchange, strlen(table->exchange));    memcpy(_stock.board, table->board, strlen(table->board));    memcpy(_stock.time, table->time, strlen(table->time));    memcpy(_stock.paper, table->paper, strlen(table->paper));    _stock.bid = to_double(table->bid);    _stock.bid_depth = (unsigned int)atoi(table->bid_depth);    _stock.bid_depth_total = (unsigned int)atoi(table->bid_depth_total);    _stock.bid_number = (unsigned int)atoi(table->bid_number);    _stock.offer = to_double(table->offer);    _stock.offer_depth = (unsigned int)atoi(table->offer_depth);    _stock.offer_depth_total = (unsigned int)atoi(table->offer_depth_total);    _stock.offer_number = (unsigned int)atoi(table->offer_number);    _stock.open = to_double(table->open);    _stock.high = to_double(table->high);    _stock.low = to_double(table->low);    _stock.last = to_double(table->last);    _stock.change = to_double(table->change);    _stock.change_percent = to_double(table->change_percent);    _stock.volume = (unsigned int)atoi(table->volume);    _stock.value = to_double(table->value);    _stock.trades = (unsigned int)atoi(table->trades);    return _stock;}
开发者ID:pkadev,项目名称:pt_server,代码行数:29,


示例11: Expression_lte

Expression* Expression_lte(Expression* x, Expression* y){  if (x == null || y == null || x->type <= number || y->type <= number) {    printf ("Error: lte - invalid arguments"); return nil_;  }  if (x->type == integer && y->type == integer) {    return (*((int*)x->car) <= *((int*)y->car)) ? t_ : nil_;  } else if (x->type == real ||  y->type == real) {    return (to_double(x) <= to_double(y)) ? t_ : nil_;  }}
开发者ID:antoinevg,项目名称:xo-lambda,代码行数:11,


示例12: qll_solver

/// /brief qll solver// l0 first linear eqn// l1 second linear eqn// xi,yi,ti  indexes to shuffle around// xk, yk, kk, rk = params of one ('last') quadratic site (point or arc)// solns = output solution triplets (x,y,t) or (u,v,t)// returns number of solutions foundint qll_solver( const std::vector< Eq<qd_real> >& lins, int xi, int yi, int ti,       const Eq<qd_real>& quad, qd_real k3, std::vector<Solution>& solns) {     assert( lins.size() == 2 );    qd_real ai = lins[0][xi]; // first linear     qd_real bi = lins[0][yi];    qd_real ki = lins[0][ti];    qd_real ci = lins[0].c;        qd_real aj = lins[1][xi]; // second linear    qd_real bj = lins[1][yi];    qd_real kj = lins[1][ti];    qd_real cj = lins[1].c;        qd_real d = chop( ai*bj - aj*bi ); // chop! (determinant for 2 linear eqns (?))    if (d == 0) // no solution can be found!        return -1;    // these are the w-equations for qll_solve()    // (2) u = a1 w + b1    // (3) v = a2 w + b2    qd_real a0 =  (bi*kj - bj*ki) / d;    qd_real a1 = -(ai*kj - aj*ki) / d;    qd_real b0 =  (bi*cj - bj*ci) / d;    qd_real b1 = -(ai*cj - aj*ci) / d;    // based on the 'last' quadratic of (s1,s2,s3)    qd_real aargs[3][2];    aargs[0][0] = 1.0;    aargs[0][1] = quad.a;    aargs[1][0] = 1.0;    aargs[1][1] = quad.b;    aargs[2][0] = -1.0;    aargs[2][1] = quad.k;        qd_real isolns[2][3];    // this solves for w, and returns either 0, 1, or 2 triplets of (u,v,t) in isolns    // NOTE: indexes of aargs shuffled depending on (xi,yi,ti) !    int scount = qll_solve( aargs[xi][0], aargs[xi][1],                            aargs[yi][0], aargs[yi][1],                            aargs[ti][0], aargs[ti][1],                            quad.c, // xk*xk + yk*yk - rk*rk,                            a0, b0,                             a1, b1, isolns);    double tsolns[2][3];    for (int i=0; i<scount; i++) {        tsolns[i][xi] = to_double(isolns[i][0]);       // u       x        tsolns[i][yi] = to_double(isolns[i][1]);       // v       y        tsolns[i][ti] = to_double(isolns[i][2]);       // t       t  chop!        solns.push_back( Solution( Point( tsolns[i][0], tsolns[i][1] ),                          tsolns[i][2], to_double(k3) ) );    }    //std::cout << " k3="<<kk3<<" qqq_solve found " << scount << " roots/n";    return scount;}
开发者ID:TanayGahlot,项目名称:openvoronoi,代码行数:59,


示例13: test_it

void test_it(){  Q q = CGAL::simplest_rational_in_interval<Q>(-0.1, 0.1);  assert(CGAL_NTS is_zero(q));  double l = 3.1415, h = 3.1416;  q = CGAL::simplest_rational_in_interval<Q>(l, h);  assert(l <= CGAL_NTS to_double(q));  assert(CGAL_NTS to_double(q) <= h);    double d = 1234.56789;  q = CGAL:: to_rational<Q>(d);  assert(CGAL_NTS to_double(q) == d);}
开发者ID:ArcEarth,项目名称:cgal,代码行数:14,


示例14: Vector3

inline double GodRaysSampler::getCache(int x, int y, int z) {    double *cache = data + z * samples_x * samples_y + y * samples_x + x;    if (*cache < 0.0) {        Vector3 location = Vector3(bounds->getStart().x + sampling_step * to_double(x),                                   bounds->getStart().y + sampling_step * to_double(y),                                   bounds->getStart().z + sampling_step * to_double(z));        double unfiltered_power = getRawLight(location, false).getPower();        if (unfiltered_power == 0.0) {            *cache = 1.0;        } else {            *cache = getRawLight(location, true).getPower() / unfiltered_power;        }    }    return *cache;}
开发者ID:thunderk,项目名称:paysages3d,代码行数:15,


示例15: get_current_element

void xls_xml_context::characters(const pstring& str, bool transient){    if (str.empty())        return;    const xml_token_pair_t& elem = get_current_element();    if (elem.first == NS_xls_xml_ss && elem.second == XML_Data)    {        switch (m_cur_cell_type)        {            case ct_string:            {                if (transient)                    m_cur_cell_string.push_back(m_pool.intern(str).first);                else                    m_cur_cell_string.push_back(str);            }            break;            case ct_number:            {                const char* p = str.get();                m_cur_cell_value = to_double(p, p + str.size());            }            break;            default:                ;        }    }}
开发者ID:jvsg,项目名称:orcus,代码行数:30,


示例16: toCargs

toCargs *readArgs(int argc, char *argv[]){  toCargs *pars = new toCargs();    int start = 1;  while (start<argc){    if(!strcmp(argv[start],"-g")){      pars->data = readmatrix(argv[start+1]);    }    else if(!strcmp(argv[start],"-LD")){      pars->LD = atoi( argv[start+1]);    }    else if(!strcmp(argv[start],"-back")){      pars->back =to_int ( argv[start+1],0,0);    }    else if(!strcmp(argv[start],"-threshold")){      pars->prune_val =to_double(std::string(argv[start+1]));    }    else if(!strcmp(argv[start],"-filename")){      pars->data_filename = std::string(argv[start+1]);    }    else if(!strcmp(argv[start],"-snps")){      pars->usedSnps_filename = std::string(argv[start+1]);    }    else{      printf("/t->Command line option not recognized: /t%s/n",argv[start]);      exit(0);    }    start+=2;  }  return pars;}
开发者ID:Arhodes-CGRB-OSU,项目名称:NgsRelate,代码行数:31,


示例17: to_double

void RenderProgress::add(int value) {    lock->acquire();    global += step * to_double(value);    lock->release();}
开发者ID:thunderk,项目名称:paysages3d,代码行数:7,


示例18: main

int main(){    for( std::string str : {                "-12345", "0xabcde", "03562", "+23.45", "-0X234P-5", "+INFINITY", "NAN", "abcd", "-1245y", "0xabkde"            } )    {        std::cout << '/n' << str << " => " ;        // try integer        try {            int v = to_integer(str) ;            std::cout << v << " (integer)/n" ;        }        catch(...)        {            // not integer, try double            try {                double v = to_double(str) ;                std::cout << v << " (double)/n" ;            }            // not double            catch(...) {                std::cout << str << " (string)/n" ;            }        }    }}
开发者ID:CCJY,项目名称:coliru,代码行数:29,


示例19: to_double

void VACExtension::printStat(bool ini){    if (ToulBar2::verbose >= 0) {        long double mean = to_double(sumlb) / (long double)nlb;        cout << "VAC mean lb/incr: " << mean << "     total increments: " << nlb                << "     cyclesize: " << (double)sumvars /                (double)nlb << "     k: " << (double)sumk /                (double)nlb << " (mean), " << theMaxK << " (max)" << endl;        if (ini)            cout << "Lb after VAC: " << wcsp->getLb() << endl;    }    //sort(heap.begin(), heap.end(), cmp_function);    /*cout << "Vars: ";	   vector<tVACStat*>::iterator it = heap.begin();	   while(it != heap.end()) {	   tVACStat* v = *it;	   if(v->sumlb != MIN_COST) cout << "(" << v->var << "," << v->sumlb << ") "; 	   ++it;	   }	   cout << endl; */    sumk = 0;    theMaxK = 0;    sumvars = 0;    sumlb = MIN_COST;    nlb = 0;}
开发者ID:eomahony,项目名称:Numberjack,代码行数:27,


示例20: throw

bool ResponseReader::read_token(std::string::size_type& start_pos, bool finished, double& result, bool require) throw (P4PProtocolError){    std::string s;    bool res = read_token(start_pos, finished, s, require);    if (res)        result = to_double(s);    return res;}
开发者ID:Yale-LANS,项目名称:ALTO,代码行数:8,


示例21: switch

double ConstantGenerator::eval_double(const ExprNode& expr) {	Domain d=eval(expr);	switch(number_type) {	case NEG_INF: return NEG_INFINITY;	case POS_INF: return POS_INFINITY;	default:      return to_double(d); //eval(expr));	}}
开发者ID:dvinc,项目名称:ibex-lib,代码行数:8,


示例22: Mutex

RenderProgress::RenderProgress(int count) {    lock = new Mutex();    global = 0.0;    step = 1.0 / to_double(count);    start_time = 0;    end_time = 0;    reset();}
开发者ID:thunderk,项目名称:paysages3d,代码行数:8,


示例23: main

int main(){  AK ak; // an object of   AK::Construct_algebraic_real_1 construct_algreal_1 = ak.construct_algebraic_real_1_object();  std::cout << "Construct from int         : " << construct_algreal_1(int(2)) << "/n";  std::cout << "Construct from Coefficient : " << construct_algreal_1(Coefficient(2)) << "/n";  std::cout << "Construct from Bound       : " << construct_algreal_1(Bound(2)) << "/n/n";  Polynomial_1 x = CGAL::shift(AK::Polynomial_1(1),1); // the monomial x  std::cout << "Construct by index              : "            << construct_algreal_1(x*x-2,1) << "/n"            << to_double(construct_algreal_1(x*x-2,1)) << "/n";  std::cout << "Construct by isolating interval : "            << construct_algreal_1(x*x-2,Bound(0),Bound(2)) << "/n"            << to_double(construct_algreal_1(x*x-2,Bound(0),Bound(2))) << "/n/n";  return 0;}
开发者ID:2php,项目名称:cgal,代码行数:18,


示例24: shape_cb

static void shape_cb(gen_ptr g, void *data){    stomperosc_data_ptr p;    p = (stomperosc_data_ptr) g->data;    p->exp = double_clip(to_double(data), 0.0, 100.0);    //Stomper acts strangely for square waves    //turns 0 to 100 into the duty cycle    //with 0-->0, 1-->0.5, 100-->1    p->duty = pow(p->exp * 0.01, LOG2OVERLOG100);}
开发者ID:blynn,项目名称:bliss,代码行数:10,


示例25: loadDoubleArray

int XMIResource::loadDoubleArray(xmlTextReaderPtr reader, enum object_properties_t property, const model::BaseObject& o){    std::vector<double> v;    controller.getObjectProperty(o.id(), o.kind(), property, v);    v.push_back(to_double(xmlTextReaderConstValue(reader)));    controller.setObjectProperty(o.id(), o.kind(), property, v);    return 1;}
开发者ID:ScilabOrg,项目名称:scilab,代码行数:10,


示例26: Expression_sub

Expression* Expression_sub(Expression* x, Expression* y){  ExpressionType type = (x->type == real || y->type == real) ? real : integer;   void* p;  if (type == integer) {    int* result = malloc(sizeof(int));    *result = *((int*)x->car) - *((int*)y->car);    p = (void*)result;  } else if (type == real) {    double* result = malloc(sizeof(double));    *result = to_double(x) - to_double(y);    p = (void*)result;  }  _gc_protect(x); _gc_protect(y);  Expression* z = _new_Expression(type);  _gc_unprotect(y); _gc_unprotect(x);  z->car = p;  return z;}
开发者ID:antoinevg,项目名称:xo-lambda,代码行数:19,


示例27: main

int main(int argc, const char * argv[]) {	char test[420];	printf("Enter a smallish number: ");	scanf("%[^/n]%*c", test);	if (is_valid_int(test))		modtest(to_int(test));	printf("/n%d/t%d/n",is_valid_int(test),to_int(test));	printf("%d/t%g/n",is_valid_number(test),to_double(test));	return 420;}
开发者ID:duck57,项目名称:Euchre-C,代码行数:10,


示例28: pre_process_hook

void cls_op::do_process(const tuple_ptr tup, int){	pre_process_hook(tup);	std::vector<double> coordinates = std::vector<double>(m_value_d);	for (int i = 0; i < m_value_d; i++)		coordinates[i] = to_double((*tup)[i]);	long timestamp = to_long(tup->op_arrival_time());	std::vector<cls_snapshot_microcluster*> *smc = m_clustream->process(coordinates, timestamp);	if (smc != NULL) {		cls_lbgu *lbgu = new cls_lbgu(smc, m_value_k);		lbgu->start();		std::vector<cls_cluster*> result = lbgu->get_clusters();		std::vector<std::pair<int, cls_cluster*> > result_list(0);		for (int i = 0; i < m_value_k; i++)			result_list.push_back(std::pair<int, cls_cluster*>(i, result[i]));		m_id++;		if (m_first_output_done) {			m_new_list   = sort_clusters(m_old_list, result_list);			m_difference = calculate_difference(m_old_list, m_new_list);		} else {			m_new_list   = result_list;			m_difference = result_list;			m_first_output_done = true;		}		std::vector<std::pair<int, cls_cluster*> > output_list;		if (m_output_version == 0)			output_list = m_new_list;		else if (m_output_version == 1)			output_list = m_difference;		else			output_list = m_new_list;		for (int i = 0; i < (int) output_list.size(); i++) {			std::vector<boost::any> data(2 + m_value_d);			data[0] = m_id;			data[1] = output_list[i].first;			for (int j = 0; j < m_value_d; j++)				data[j+2] = output_list[i].second->get_coordinate(j);			tuple_ptr n_tuple(new tuple(data));			publish_new(n_tuple);		}		m_old_list = m_new_list;	}}
开发者ID:CCJY,项目名称:engine-1,代码行数:55,



注:本文中的to_double函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ to_ehrpwm_pwm函数代码示例
C++ to_device_private_bus函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。