当前位置: 首页>>代码示例>>C++>>正文


C++ push_number函数代码示例

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


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

示例1: handle_read

void handle_read(struct request *req, int val){
    aiob *aio = req->aio;
    close(aio->aio_fildes);
    if(val){
        FREE(aio->aio_buf);
        push_number(val);
        set_eval(max_cost);
        safe_call_efun_callback(req->fun, 1);
        return;
    }
    val = aio_return(aio);
    if(val < 0){
        FREE(aio->aio_buf);
        push_number(val);
        set_eval(max_cost);
        safe_call_efun_callback(req->fun, 1);
        return;
    }
    char *file = new_string(val, "read_file_async: str");
    memcpy(file, (char *)(aio->aio_buf), val);
    file[val]=0;
    push_malloced_string(file);
    FREE(aio->aio_buf);
    set_eval(max_cost);
    safe_call_efun_callback(req->fun, 1);
}
开发者ID:Hobbitron,项目名称:tmi2_fluffos_v3,代码行数:26,代码来源:async.c

示例2: bmod

static void
bmod(void)
{
	struct number *a, *b, *r;
	BN_CTX *ctx;
	u_int scale;

	a = pop_number();
	if (a == NULL)
		return;
	b = pop_number();
	if (b == NULL) {
		push_number(a);
		return;
	}

	r = new_number();
	scale = max(a->scale, b->scale);
	r->scale = scale;

	if (BN_is_zero(a->number))
		warnx("remainder by zero");
	else {
		normalize(a, scale);
		normalize(b, scale);

		ctx = BN_CTX_new();
		bn_checkp(ctx);
		bn_check(BN_mod(r->number, b->number, a->number, ctx));
		BN_CTX_free(ctx);
	}
	push_number(r);
	free_number(a);
	free_number(b);
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:35,代码来源:bcode.c

示例3: eval

void eval(stack **n_stack, stack **o_stack, double *x, double *y){
	//Using easier names
	char op=top_operator(*o_stack);
	double n1, n2;
		
	//Checking the different cases for the top of the stack
	if(op=='='){
		pop_operator(&(*o_stack));
		if(pop_operator(&(*o_stack))=='x')
			*x=top_number(*n_stack);
		else
			*y=top_number(*n_stack);
	}
	else if(op=='x'){
		pop_operator(&(*o_stack));
		push_number(*x, &(*n_stack));
	}
	else if(op=='y'){
		pop_operator(&(*o_stack));
		push_number(*y, &(*n_stack));
	}
	else{//Push the computed result into the n_stack
		n1=pop_number(&(*n_stack));
		n2=pop_number(&(*n_stack));
		op=pop_operator(&(*o_stack));
		push_number(compute(n1, op, n2), &(*n_stack));
	}
}
开发者ID:srijanshetty,项目名称:DS,代码行数:28,代码来源:expression_evaluation.c

示例4: bsub

static void
bsub(void)
{
	struct number	*a, *b, *r;

	a = pop_number();
	if (a == NULL)
		return;
	b = pop_number();
	if (b == NULL) {
		push_number(a);
		return;
	}

	r = new_number();

	r->scale = max(a->scale, b->scale);
	if (r->scale > a->scale)
		normalize(a, r->scale);
	else if (r->scale > b->scale)
		normalize(b, r->scale);
	bn_check(BN_sub(r->number, b->number, a->number));
	push_number(r);
	free_number(a);
	free_number(b);
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:26,代码来源:bcode.c

示例5: f_bson_buf_find

void f_bson_buf_find(void){
	int size;
	bson b[1];
	bson  sub;
	svalue_t v;
	bson_iterator it;

	size = (sp-1)->u.buf->size;
	bson_init_empty(b);
	bson_init_size( b, size );
	memcpy(b->data, (sp-1)->u.buf->item, size);
	b->finished = 1;

	/* buff不合法 */
	if(bson_size(b) != size){
		pop_n_elems(st_num_arg);
		push_number(0);
		goto free_bson;
	}
	/* 找不到数据 */
	if(!bson_find( &it, b, sp->u.string )){
		pop_n_elems(st_num_arg);
		push_number(0);
		goto free_bson;
	}
	bson_to_v(&it, &v);
	free_buffer((sp-1)->u.buf);
	pop_stack();
	*sp = v;
free_bson:
	bson_destroy( b );
}
开发者ID:carriercomm,项目名称:mudos-1,代码行数:32,代码来源:mg.c

示例6: efun_cat_file

static void
efun_cat_file(struct svalue *fp)
{
    extern int read_file_len;
    char *str;
    
    if (fp[0].type != T_STRING || fp[1].type != T_NUMBER
	|| fp[2].type != T_NUMBER)
    {
	push_number(0);
	return;
    }
    str = read_file(fp[0].u.string, fp[1].u.number, fp[2].u.number);
    if (str)
    {
	push_mstring(str);
	if (command_giver)
	    (void)apply("catch_tell", command_giver, 1, 0);
	else
	    (void)apply("catch_tell", current_interactive, 1, 0);
	push_number(read_file_len);
    }
    else
	push_number(0);
}
开发者ID:arszenik,项目名称:cd-gamedriver,代码行数:25,代码来源:efun.c

示例7: efun_atoi

static void
efun_atoi(struct svalue *fp)
{
    if (fp->type == T_STRING)
	push_number(atoi(fp->u.string));
    else
	push_number(0);
}
开发者ID:arszenik,项目名称:cd-gamedriver,代码行数:8,代码来源:efun.c

示例8: bdivmod

static void
bdivmod(void)
{
	struct number *a, *b, *frac, *quotient, *rdiv, *remainder;
	BN_CTX *ctx;
	u_int scale;

	a = pop_number();
	if (a == NULL)
		return;
	b = pop_number();
	if (b == NULL) {
		push_number(a);
		return;
	}

	rdiv = new_number();
	quotient = new_number();
	remainder = new_number();
	scale = max(a->scale, b->scale);
	rdiv->scale = 0;
	remainder->scale = scale;
	quotient->scale = bmachine.scale;
	scale = max(a->scale, b->scale);

	if (BN_is_zero(a->number))
		warnx("divide by zero");
	else {
		normalize(a, scale);
		normalize(b, scale);

		ctx = BN_CTX_new();
		bn_checkp(ctx);
		/*
		 * Unlike other languages' divmod operations, dc is specified
		 * to return the remainder and the full quotient, rather than
		 * the remainder and the floored quotient.  bn(3) has no
		 * function to calculate both.  So we'll use BN_div to get the
		 * remainder and floored quotient, then calculate the full
		 * quotient from those.
		 *
		 * quotient = rdiv + remainder / divisor
		 */
		bn_check(BN_div(rdiv->number, remainder->number,
		    b->number, a->number, ctx));
		frac = div_number(remainder, a, bmachine.scale);
		normalize(rdiv, bmachine.scale);
		normalize(remainder, scale);
		bn_check(BN_add(quotient->number, rdiv->number, frac->number));
		free_number(frac);
		BN_CTX_free(ctx);
	}
	push_number(quotient);
	push_number(remainder);
	free_number(rdiv);
	free_number(a);
	free_number(b);
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:58,代码来源:bcode.c

示例9: test

static void
test(struct hash *h) {
	push_number(h, "a" , 1.0);
	push_string(h, "b" , "hello world");
	push_nil(h, "c");
	int i;
	char buffer[10];
	for (i=0;i<100;i++) {
		sprintf(buffer,"%d",i*2);
		push_number(h,buffer,i);
	}
	debug_table(h);
	hash_genpool(h);
}
开发者ID:ChowZenki,项目名称:lua-db,代码行数:14,代码来源:testhash.c

示例10: load_array

static void
load_array(void)
{
	int			reg;
	struct number		*inumber, *n;
	u_long			index;
	struct stack		*stack;
	struct value		*v, copy;

	reg = readreg();
	if (reg >= 0) {
		inumber = pop_number();
		if (inumber == NULL)
			return;
		index = get_ulong(inumber);
		if (BN_cmp(inumber->number, &zero) < 0)
			warnx("negative index");
		else if (index == BN_MASK2 || index > MAX_ARRAY_INDEX)
			warnx("index too big");
		else {
			stack = &bmachine.reg[reg];
			v = frame_retrieve(stack, index);
			if (v == NULL) {
				n = new_number();
				bn_check(BN_zero(n->number));
				push_number(n);
			}
			else
				push(stack_dup_value(v, &copy));
		}
		free_number(inumber);
	}
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:33,代码来源:bcode.c

示例11: parse_number

static void
parse_number(void)
{
	unreadch();
	push_number(readnumber(&bmachine.readstack[bmachine.readsp],
	    bmachine.ibase));
}
开发者ID:darksoul42,项目名称:bitrig,代码行数:7,代码来源:bcode.c

示例12: load_array

static void
load_array(void)
{
	struct number *inumber, *n;
	struct stack *stack;
	struct value *v;
	struct value copy;
	u_long idx;
	int reg;

	reg = readreg();
	if (reg >= 0) {
		inumber = pop_number();
		if (inumber == NULL)
			return;
		idx = get_ulong(inumber);
		if (BN_is_negative(inumber->number))
			warnx("negative idx");
		else if (idx == ULONG_MAX || idx > MAX_ARRAY_INDEX)
			warnx("idx too big");
		else {
			stack = &bmachine.reg[reg];
			v = frame_retrieve(stack, idx);
			if (v == NULL || v->type == BCODE_NONE) {
				n = new_number();
				bn_check(BN_zero(n->number));
				push_number(n);
			}
			else
				push(stack_dup_value(v, &copy));
		}
		free_number(inumber);
	}
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:34,代码来源:bcode.c

示例13: push_scale

static void
push_scale(void)
{
	struct value	*value;
	u_int		scale = 0;
	struct number	*n;


	value = pop();
	if (value != NULL) {
		switch (value->type) {
		case BCODE_NONE:
			return;
		case BCODE_NUMBER:
			scale = value->u.num->scale;
			break;
		case BCODE_STRING:
			break;
		}
		stack_free_value(value);
		n = new_number();
		bn_check(BN_set_word(n->number, scale));
		push_number(n);
	}
}
开发者ID:darksoul42,项目名称:bitrig,代码行数:25,代码来源:bcode.c

示例14: num_digits

static void
num_digits(void)
{
	struct number *n = NULL;
	struct value *value;
	size_t digits;

	value = pop();
	if (value != NULL) {
		switch (value->type) {
		case BCODE_NONE:
			return;
		case BCODE_NUMBER:
			digits = count_digits(value->u.num);
			n = new_number();
			bn_check(BN_set_word(n->number, digits));
			break;
		case BCODE_STRING:
			digits = strlen(value->u.string);
			n = new_number();
			bn_check(BN_set_word(n->number, digits));
			break;
		}
		stack_free_value(value);
		push_number(n);
	}
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:27,代码来源:bcode.c

示例15: bsqrt

static void
bsqrt(void)
{
	struct number	*n;
	struct number	*r;
	BIGNUM		*x, *y;
	u_int		scale, onecount;
	BN_CTX		*ctx;

	onecount = 0;
	n = pop_number();
	if (n == NULL) {
		return;
	}
	if (BN_is_zero(n->number)) {
		r = new_number();
		push_number(r);
	} else if (BN_is_negative(n->number))
		warnx("square root of negative number");
	else {
		scale = max(bmachine.scale, n->scale);
		normalize(n, 2*scale);
		x = BN_dup(n->number);
		bn_checkp(x);
		bn_check(BN_rshift(x, x, BN_num_bits(x)/2));
		y = BN_new();
		bn_checkp(y);
		ctx = BN_CTX_new();
		bn_checkp(ctx);
		for (;;) {
			bn_checkp(BN_copy(y, x));
			bn_check(BN_div(x, NULL, n->number, x, ctx));
			bn_check(BN_add(x, x, y));
			bn_check(BN_rshift1(x, x));
			if (bsqrt_stop(x, y, &onecount))
				break;
		}
		r = bmalloc(sizeof(*r));
		r->scale = scale;
		r->number = y;
		BN_free(x);
		BN_CTX_free(ctx);
		push_number(r);
	}

	free_number(n);
}
开发者ID:darksoul42,项目名称:bitrig,代码行数:47,代码来源:bcode.c


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