• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NUM函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _mpq_cmp_si

int
_mpq_cmp_si (mpq_srcptr q, long n, unsigned long d)
{
  /* need canonical sign to get right result */
  ASSERT (SIZ(DEN(q)) > 0);

  if (SIZ(NUM(q)) >= 0)
    {
      if (n >= 0)
        return _mpq_cmp_ui (q, n, d);            /* >=0 cmp >=0 */
      else
        return 1;                                /* >=0 cmp <0 */
    }
  else
    {
      if (n >= 0)
        return -1;                               /* <0 cmp >=0 */
      else
        {
          mpq_t  qabs;
          SIZ(NUM(qabs)) = ABSIZ(NUM(q));
          PTR(NUM(qabs)) = PTR(NUM(q));
          SIZ(DEN(qabs)) = SIZ(DEN(q));
          PTR(DEN(qabs)) = PTR(DEN(q));

          return - _mpq_cmp_ui (qabs, NEG_CAST (unsigned long, n), d);    /* <0 cmp <0 */
        }
    }
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:29,代码来源:cmp_si.c


示例2: while

Object *Builtin_subtract(ListObject *arg, ListObject *context)
{
	NumberObject *ret = NULL;

	int i = 0;
	while (i < arg->len)
	{
		Object *term = arg->arr[i];
		if (Object_istype(term, NUMBER_OBJECT))
		{
			if (i == 0)
			{
				double init = NUM(term)->value;
				if (arg->len == 1)
					init = -init;
				ret = new_NumberObject(init);
			}
			else
				NUM(ret)->value -= NUM(term)->value;
		}
		else
		{
			if (ret != NULL)
				del_Object(OBJ(ret));
			ret = NULL;
			break;
		}
		i++;
	}
	if (ret == NULL)
		cause_error(INCORRECT_ARGUMENT_ERROR, "(<number> <number> ...)", 23);

	return OBJ(ret);
}
开发者ID:mattragoza,项目名称:mantra,代码行数:34,代码来源:builtin.c


示例3: mpq_set_ui

void
mpq_set_ui (MP_RAT *dest, unsigned long int num, unsigned long int den)
{
  if (GMP_NUMB_BITS < BITS_PER_ULONG)
    {
      if (num == 0)  /* Canonicalize 0/d to 0/1.  */
        den = 1;
      mpz_set_ui (mpq_numref (dest), num);
      mpz_set_ui (mpq_denref (dest), den);
      return;
    }

  if (num == 0)
    {
      /* Canonicalize 0/n to 0/1.  */
      den = 1;
      SIZ(NUM(dest)) = 0;
    }
  else
    {
      PTR(NUM(dest))[0] = num;
      SIZ(NUM(dest)) = 1;
    }

  PTR(DEN(dest))[0] = den;
  SIZ(DEN(dest)) = (den != 0);
}
开发者ID:AlexeiSheplyakov,项目名称:gmp.pkg,代码行数:27,代码来源:set_ui.c


示例4: main

int main(){
       int n,k,year,m,i,j; 
	   char mon[12][12]={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};
	   printf("输入年份\n");
	   scanf("%d",&year);
	   if(isleayear(year)==1 || year<2000)
	     n=(int)(fabs(year-2000)*365+(int)fabs(year-2000)/4)%7;                //判断某年一月一号为星期几
	   else
         n=(int)(fabs(year-2000)*365+(int)fabs(year-2000)/4+1)%7;
	   if(year<2000)n=7-n;                                                     //当年份小于2000是一月一号星期几
	   for(k=0;k<12;++k){
	      printf("%s\n日 一 二 三 四 五 六\n",mon[k]);
          if(n==0) n+=7;
		  else 
			  if(n==8)
				  n=1;
	      m=1;
		  for(j=0;j<n-1;++j)					
			  printf("   ");
		  for(j=n-1;j<7;++j){
			  printf("%2d%c",m,j==6? '\n': ' ');
			  m=m+1;
		  }	
		  for(i=1;i<=5;++i){
			  for(j=0;j<7&&m<=NUM(year,k);++j){
			  	   printf("%2d%c",m,j==6? '\n': ' ');
				   m=m+1;
                   if(m-1==NUM(year,k)){n=j+2;printf("\n");break;}                //输出年历
			  }
		  }
		 }
return 0;
}
开发者ID:yangyang0312,项目名称:C-,代码行数:33,代码来源:no1.cpp


示例5: mpq_clear

void
mpq_clear (MP_RAT *m)
{
  (*__gmp_free_func) (PTR(NUM(m)),
		    ALLOC(NUM(m)) * BYTES_PER_MP_LIMB);
  (*__gmp_free_func) (PTR(DEN(m)),
		    ALLOC(DEN(m)) * BYTES_PER_MP_LIMB);
}
开发者ID:AlexeiSheplyakov,项目名称:gmp.pkg,代码行数:8,代码来源:clear.c


示例6: mpq_clear

void
mpq_clear (mpq_t m)
{
  (*__gmp_free_func) (PTR(NUM(m)),
		    (size_t) ALLOC(NUM(m)) * GMP_LIMB_BYTES);
  (*__gmp_free_func) (PTR(DEN(m)),
		    (size_t) ALLOC(DEN(m)) * GMP_LIMB_BYTES);
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:8,代码来源:clear.c


示例7: set_option_var

int
set_option_var(const option_t *options, const char *var, const char *val,
    char *buf, size_t len)
{
	char *s;
	size_t i;

#define NUM(type) \
	if (!*val) { \
		*(type *)options[i].value = 1; \
		break; \
	} \
	*(type *)options[i].value = (type)strsuftoll(options[i].desc, val, \
	    options[i].minimum, options[i].maximum); break

	for (i = 0; options[i].name != NULL; i++) {
		if (var[1] == '\0') {
			if (options[i].letter != var[0])
				continue;
		} else if (strcmp(options[i].name, var) != 0)
			continue;
		switch (options[i].type) {
		case OPT_BOOL:
			*(bool *)options[i].value = 1;
			break;
		case OPT_STRARRAY:
			strlcpy((void *)options[i].value, val, (size_t)
			    options[i].maximum);
			break;
		case OPT_STRPTR:
			s = estrdup(val);
			*(char **)options[i].value = s;
			break;
		case OPT_STRBUF:
			if (buf == NULL)
				abort();
			strlcpy(buf, val, len);
			break;
		case OPT_INT64:
			NUM(uint64_t);
		case OPT_INT32:
			NUM(uint32_t);
		case OPT_INT16:
			NUM(uint16_t);
		case OPT_INT8:
			NUM(uint8_t);
		default:
			warnx("Unknown type %d in option %s", options[i].type,
			    val);
			return 0;
		}
		return i;
	}
	warnx("Unknown option `%s'", var);
	return -1;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:56,代码来源:makefs.c


示例8: pdf_to_offset

fz_off_t pdf_to_offset(fz_context *ctx, pdf_obj *obj)
{
	RESOLVE(obj);
	if (obj < PDF_OBJ__LIMIT)
		return 0;
	if (obj->kind == PDF_INT)
		return NUM(obj)->u.i;
	if (obj->kind == PDF_REAL)
		return (fz_off_t)(NUM(obj)->u.f + 0.5f); /* No roundf in MSVC */
	return 0;
}
开发者ID:camlhsegu,项目名称:mupdf,代码行数:11,代码来源:pdf-object.c


示例9: pdf_to_real

float pdf_to_real(fz_context *ctx, pdf_obj *obj)
{
	RESOLVE(obj);
	if (obj < PDF_OBJ__LIMIT)
		return 0;
	if (obj->kind == PDF_REAL)
		return NUM(obj)->u.f;
	if (obj->kind == PDF_INT)
		return NUM(obj)->u.i;
	return 0;
}
开发者ID:camlhsegu,项目名称:mupdf,代码行数:11,代码来源:pdf-object.c


示例10: apply_closure

PUBLIC INLINE void apply_closure(VMSTATE vms, OVECTOR closure, VECTOR argvec) {
  if (closure == NULL || TAGGEDP(closure)) {
    vm_raise(vms, (OBJ) newsym("invalid-callable"), (OBJ) closure);
  } else if (closure->type == T_PRIM) {
    int primargc;
    prim_fn fnp = lookup_prim(NUM(AT(closure, PR_NUMBER)), &primargc);

    if (fnp != NULL) {
      if ((primargc >= 0 && argvec->_.length-1 != primargc) ||
	  (primargc < 0 && argvec->_.length-1 < -primargc))
	vm_raise(vms, (OBJ) newsym("wrong-argc"), (OBJ) closure);
      else
	vms->r->vm_acc = fnp(vms, argvec);
    } else
      vm_raise(vms, (OBJ) newsym("invalid-primitive"), AT(closure, PR_NUMBER));
  } else if (closure->type == T_CLOSURE) {
    OVECTOR meth = (OVECTOR) AT(closure, CL_METHOD);

    if (!MS_CAN_X(meth, vms->r->vm_effuid)) {
      vm_raise(vms, (OBJ) newsym("no-permission"), AT(meth, ME_NAME));
      return;
    }

    if (argvec->_.length-1 != NUM(AT(meth, ME_ARGC))) {
      vm_raise(vms, (OBJ) newsym("wrong-argc"), (OBJ) meth);
      return;
    }

    push_frame(vms);

    vms->r->vm_env = argvec;
    ATPUT(vms->r->vm_env, 0, AT(meth, ME_ENV));

    vms->r->vm_lits = (VECTOR) AT(meth, ME_LITS);
    vms->r->vm_code = (BVECTOR) AT(meth, ME_CODE);
    vms->r->vm_self = (OBJECT) AT(closure, CL_SELF);
    vms->c.vm_ip = 0;
    vms->r->vm_method = meth;
    if (NUM(AT(meth, ME_FLAGS)) & O_SETUID)
      vms->r->vm_effuid = (OBJECT) AT(meth, ME_OWNER);
  } else if (closure->type == T_CONTINUATION) {
    int i;
    VECTOR cstk = (VECTOR) AT(closure, CONT_STACK);

    for (i = 0; i < cstk->_.length; i++)
      ATPUT(vms->r->vm_stack, i, AT(cstk, i));
    vms->c.vm_top = cstk->_.length;

    restoreframe(vms, (OVECTOR) AT(closure, CONT_FRAME));
    vms->r->vm_acc = AT(argvec, 1);
  } else {
    vm_raise(vms, (OBJ) newsym("invalid-callable"), (OBJ) closure);
  }
}
开发者ID:giantfishy,项目名称:3-move,代码行数:54,代码来源:vm.c


示例11: mpq_set_num

void
mpq_set_num (mpq_ptr dest, mpz_srcptr num)
{
  mp_size_t size = SIZ (num);
  mp_size_t abs_size = ABS (size);
  mp_ptr dp;

  dp = MPZ_NEWALLOC (NUM(dest), abs_size);

  SIZ(NUM(dest)) = size;
  MPN_COPY (dp, PTR(num), abs_size);
}
开发者ID:AlexeiSheplyakov,项目名称:gmp.pkg,代码行数:12,代码来源:set_num.c


示例12: scull_w_open

int scull_w_open (struct inode *inode, struct file *filp)
{
    Scull_Dev *dev = &scull_w_device; /* device information */
    int num = NUM(inode->i_rdev);

    if (num > 0) return -ENODEV; /* 1 device only */
    while (scull_w_count && 
      (scull_w_owner != current->uid) &&  /* allow user */
      (scull_w_owner != current->euid) && /* allow whoever did su */
      !suser()) {
        if (filp->f_flags & O_NONBLOCK) return -EAGAIN; 
        interruptible_sleep_on(&scull_w_wait);
        if (current->signal & ~current->blocked) /* a signal arrived */
          return -ERESTARTSYS; /* tell the fs layer to handle it */
        /* else, loop */
    }
    if (scull_w_count == 0)
        scull_w_owner = current->uid; /* grab it */
    scull_w_count++;

    /* then, everything else is copied from the bare scull device */

    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)
        scull_trim(dev);
    filp->private_data = dev;
    MOD_INC_USE_COUNT;
    return 0;          /* success */
}
开发者ID:dot-Sean,项目名称:linux_drivers,代码行数:28,代码来源:access.c


示例13: ALLOC

object *number_str(const char *s)
{
    object *p = ALLOC(object);
    TYPE(p) = OBJ_NUMBER;
    sscanf(s, "%d", &NUM(p));
    return p;
}
开发者ID:medici,项目名称:Scheme-1,代码行数:7,代码来源:object.c


示例14: fillstat

static void
fillstat(Dir *d, uint32_t path)
{
	Tab *t;
	int type;
	char buf[32];

	memset(d, 0, sizeof(*d));
	d->uid = estrdup("exec");
	d->gid = estrdup("exec");
	d->qid.path = path;
	d->atime = d->mtime = time0;
	d->length = 0;

	type = TYPE(path);
	t = &tab[type];
	if(t->name)
		d->name = estrdup(t->name);
	else{
		snprint(buf, sizeof buf, "%u", NUM(path));
		d->name = estrdup(buf);
	}
	d->qid.type = t->mode>>24;
	d->mode = t->mode;
}
开发者ID:rminnich,项目名称:harvey,代码行数:25,代码来源:fs.c


示例15: scull_u_open

int scull_u_open (struct inode *inode, struct file *filp)
{
    Scull_Dev *dev = &scull_u_device; /* device information */
    int num = NUM(inode->i_rdev);

    if (num > 0) return -ENODEV; /* 1 device only */
    if (scull_u_count && 
        (scull_u_owner != current->uid) &&  /* allow user */
        (scull_u_owner != current->euid) && /* allow whoever did su */
        !suser()) /* still allow root */
         return -EBUSY;   /* -EPERM would confuse the user */

    if (scull_u_count == 0)
        scull_u_owner = current->uid; /* grab it */

    scull_u_count++;

    /* then, everything else is copied from the bare scull device */

    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)
        scull_trim(dev);
    filp->private_data = dev;
    MOD_INC_USE_COUNT;
    return 0;          /* success */
}
开发者ID:dot-Sean,项目名称:linux_drivers,代码行数:25,代码来源:access.c


示例16: scull_open

int scull_open (struct inode *inode, struct file *filp)
{
    int type = TYPE(inode->i_rdev);
    int num = NUM(inode->i_rdev);
    Scull_Dev *dev; /* device information */

    /* manage peculiar types first */
    if (type) {
        if (type > SCULL_MAX_TYPE) return -ENODEV;
        filp->f_op = scull_fop_array[type];
        return filp->f_op->open(inode, filp); /* dispatch to specific open */
    }

    /* type 0, check the device number */
    if (num >= scull_nr_devs) return -ENODEV;
    dev = &scull_devices[num];

    /* now trim to 0 the length of the device if open was write-only */
    if ( (filp->f_flags & O_ACCMODE) == O_WRONLY)
        scull_trim(dev); /* ignore errors */

    /* and use filp->private_data to point to the device data */
    filp->private_data = dev;

    MOD_INC_USE_COUNT;
    return 0;          /* success */
}
开发者ID:dot-Sean,项目名称:linux_drivers,代码行数:27,代码来源:main.c


示例17: cyg_hal_plf_serial_init

/* Early initialization of comm channels.
 */
void
cyg_hal_plf_serial_init(void)
{
    hal_virtual_comm_table_t* comm;
    int cur = CYGACC_CALL_IF_SET_CONSOLE_COMM(CYGNUM_CALL_IF_SET_COMM_ID_QUERY_CURRENT);
    int chan = 0;
    struct port_info *port;
    static int init = 0;

    if (init) return;
    init++;

    // Setup procs in the vector table    
    for (port = ports, chan = 0;  chan < NUM(ports);  chan++, port++) {        
        CYGACC_CALL_IF_SET_CONSOLE_COMM(chan);
        comm = CYGACC_CALL_IF_CONSOLE_PROCS();
        CYGACC_COMM_IF_CH_DATA_SET(*comm, port);
        CYGACC_COMM_IF_WRITE_SET(*comm, cyg_hal_plf_serial_write);
        CYGACC_COMM_IF_READ_SET(*comm, cyg_hal_plf_serial_read);
        CYGACC_COMM_IF_PUTC_SET(*comm, cyg_hal_plf_serial_putc);
        CYGACC_COMM_IF_GETC_SET(*comm, cyg_hal_plf_serial_getc);
        CYGACC_COMM_IF_CONTROL_SET(*comm, cyg_hal_plf_serial_control);
        CYGACC_COMM_IF_GETC_TIMEOUT_SET(*comm, cyg_hal_plf_serial_getc_timeout);
        if (port->is_smc) {
            cyg_hal_plf_smcx_init_channel(port, port->cpm_page);
            CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_smcx_isr);
        } else {
            cyg_hal_plf_sccx_init_channel(port, port->cpm_page);
            CYGACC_COMM_IF_DBG_ISR_SET(*comm, cyg_hal_plf_sccx_isr);
        }
    }

    // Restore original console
    CYGACC_CALL_IF_SET_CONSOLE_COMM(cur);
}
开发者ID:KarenHung,项目名称:ecosgit,代码行数:37,代码来源:quicc2_diag.c


示例18: mpq_set_z

void
mpq_set_z (mpq_ptr dest, mpz_srcptr src)
{
  mp_size_t num_size;
  mp_size_t abs_num_size;
  mp_ptr dp;

  num_size = SIZ (src);
  abs_num_size = ABS (num_size);
  dp = MPZ_NEWALLOC (NUM(dest), abs_num_size);
  SIZ(NUM(dest)) = num_size;
  MPN_COPY (dp, PTR(src), abs_num_size);

  PTR(DEN(dest))[0] = 1;
  SIZ(DEN(dest)) = 1;
}
开发者ID:AlexeiSheplyakov,项目名称:gmp.pkg,代码行数:16,代码来源:set_z.c


示例19: mpq_init

void
mpq_init (MP_RAT *x)
{
  ALLOC(NUM(x)) = 1;
  PTR(NUM(x)) = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB);
  SIZ(NUM(x)) = 0;
  ALLOC(DEN(x)) = 1;
  PTR(DEN(x)) = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB);
  PTR(DEN(x))[0] = 1;
  SIZ(DEN(x)) = 1;

#ifdef __CHECKER__
  /* let the low limb look initialized, for the benefit of mpz_get_ui etc */
  PTR(NUM(x))[0] = 0;
#endif
}
开发者ID:AlexeiSheplyakov,项目名称:gmp.pkg,代码行数:16,代码来源:init.c


示例20: mpq_init

void
mpq_init (mpq_t x)
{
  ALLOC(NUM(x)) = 1;
  PTR(NUM(x)) = __GMP_ALLOCATE_FUNC_LIMBS (1);
  SIZ(NUM(x)) = 0;
  ALLOC(DEN(x)) = 1;
  PTR(DEN(x)) = __GMP_ALLOCATE_FUNC_LIMBS (1);
  PTR(DEN(x))[0] = 1;
  SIZ(DEN(x)) = 1;

#ifdef __CHECKER__
  /* let the low limb look initialized, for the benefit of mpz_get_ui etc */
  PTR(NUM(x))[0] = 0;
#endif
}
开发者ID:AaronNGray,项目名称:texlive-libs,代码行数:16,代码来源:init.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NUM2DBL函数代码示例发布时间:2022-05-30
下一篇:
C++ NULL_PARAM_CHECK函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap