示例#1
0
static void compute_entry_length(const HashKey *hash_key, const HashValue *hash_value)
{
    symbol_length   = MAX(symbol_length, strlen(hash_key->symbol));
    filename_length = MAX(filename_length, strlen(hash_key->filename));
    nb_bytes_length = MAX(nb_bytes_length, ilog10(hash_value->size));
    nb_instr_length = MAX(nb_instr_length, ilog10(hash_value->icount));
}
示例#2
0
文件: mathutil.cpp 项目: koz4k/soccer
double ceilr(double d, int digits)
{
	int i = ilog10(d);
	if(IsNull(i))
		return d;
	double fac = ipow10(i - digits);
	return ceil(d / fac) * fac;
}
示例#3
0
文件: mathutil.cpp 项目: koz4k/soccer
double roundr(double d, int digits)
{
	int i = ilog10(d);
	if(IsNull(i))
		return d;
	double fac = ipow10(i - digits);
	return floor(d / fac + 0.5) * fac;
}
示例#4
0
void lcdPrintInt(int inum, char width) {
	char len = (inum == 0? 1 : (ilog10(inum) + 1));
	int i;
	for(i = 0; i < width - len; i++)
		lcdWrite('0', 1, 1);
	for(i = ipow10(len - 1); i > 0; inum %= i, i /= 10, len--)
			lcdWrite('0' + inum/i, 1, 1);
}
示例#5
0
文件: mathutil.cpp 项目: koz4k/soccer
double normalize(double d, int& exp)
{
	if(IsNull(d) || d == 0)
	{
		exp = Null;
		return d;
	}
	bool sign = (d < 0);
	if(sign) d = -d;
	exp = minmax<int>(ilog10(d), -300, +300); // 8-byte double!
	d /= ipow10(exp);
	if(d >= 10) { d /= 10; exp++; }
	if(d < 1)   { d *= 10; exp--; }
	return sign ? -d : d;
}
示例#6
0
void lcdPrintFloat(float fnum, char width, short prec) {
	long i , j;
	char len;

	if(fnum < 0) {
		lcdWrite('-', 1, 1);
		i = -fnum;
	} else {
		i = fnum;
	}
	len = (i == 0 ? 1 : (ilog10(i) + 1)) + prec;
	i = fnum * ipow10(prec);
	for(j = 0; j < width - len - (prec != 0); j++)
		lcdWrite('0', 1, 1);
	for(j = ipow10(len - 1); j > 0; i %= j, j /= 10, len--) {
		lcdWrite('0' + i/j, 1, 1);
		if(prec > 0 && len - 1 == prec)
			lcdWrite('.', 1, 1);
	}
}
示例#7
0
文件: stats.c 项目: aahud/harvey
int
initmach(Machine *m, char *name)
{
	int n, fd;
	uint64_t a[MAXNUM];
	char *p, mpt[256], buf[256];

	p = strchr(name, '!');
	if(p)
		p++;
	else
		p = name;
	m->name = estrdup(p);
	m->shortname = shortname(p);
	m->remote = (strcmp(p, mysysname) != 0);
	if(m->remote == 0)
		strcpy(mpt, "");
	else{
		snprint(mpt, sizeof mpt, "/n/%s", p);
		fd = connectexportfs(name);
		if(fd < 0){
			fprint(2, "can't connect to %s: %r\n", name);
			return 0;
		}
		/* BUG? need to use amount() now? */
		if(mount(fd, -1, mpt, MREPL, "", 'M') < 0){
			fprint(2, "stats: mount %s on %s failed (%r); trying /n/sid\n", name, mpt);
			strcpy(mpt, "/n/sid");
			if(mount(fd, -1, mpt, MREPL, "", 'M') < 0){
				fprint(2, "stats: mount %s on %s failed: %r\n", name, mpt);
				return 0;
			}
		}
	}

	snprint(buf, sizeof buf, "%s/dev/swap", mpt);
	m->swapfd = open(buf, OREAD);
	if(loadbuf(m, &m->swapfd) && readswap(m, a))
		memmove(m->devswap, a, sizeof m->devswap);
	else{
		m->devswap[Maxswap] = 100;
		m->devswap[Maxmem] = 100;
	}

	snprint(buf, sizeof buf, "%s/dev/sysstat", mpt);
	m->statsfd = open(buf, OREAD);
	if(loadbuf(m, &m->statsfd)){
		for(n=0; readnums(m, nelem(m->devsysstat), a, 0); n++)
			;
		m->nproc = n;
	}else
		m->nproc = 1;
	m->lgproc = ilog10(m->nproc);

	snprint(buf, sizeof buf, "%s/net/ether0/stats", mpt);
	m->etherfd = open(buf, OREAD);
	if(loadbuf(m, &m->etherfd) && readnums(m, nelem(m->netetherstats), a, 1))
		memmove(m->netetherstats, a, sizeof m->netetherstats);

	snprint(buf, sizeof buf, "%s/net/ether0/ifstats", mpt);
	m->ifstatsfd = open(buf, OREAD);
	if(loadbuf(m, &m->ifstatsfd)){
		/* need to check that this is a wavelan interface */
		if(strncmp(m->buf, "Signal: ", 8) == 0 && readnums(m, nelem(m->netetherifstats), a, 1))
			memmove(m->netetherifstats, a, sizeof m->netetherifstats);
	}

	snprint(buf, sizeof buf, "%s/mnt/apm/battery", mpt);
	m->batteryfd = open(buf, OREAD);
	m->bitsybatfd = -1;
	if(m->batteryfd >= 0){
		if(loadbuf(m, &m->batteryfd) && readnums(m, nelem(m->batterystats), a, 0))
			memmove(m->batterystats, a, sizeof(m->batterystats));
	}else{
		snprint(buf, sizeof buf, "%s/dev/battery", mpt);
		m->bitsybatfd = open(buf, OREAD);
		if(loadbuf(m, &m->bitsybatfd) && readnums(m, 1, a, 0))
			memmove(m->batterystats, a, sizeof(m->batterystats));
	}
	snprint(buf, sizeof buf, "%s/dev/cputemp", mpt);
	m->tempfd = open(buf, OREAD);
	if(loadbuf(m, &m->tempfd))
		for(n=0; n < nelem(m->temp) && readnums(m, 2, a, 0); n++)
			 m->temp[n] = a[0];
	return 1;
}
示例#8
0
文件: fixed.cpp 项目: proton/ireon
fixed fixed::log10(void)
{
	return ilog10(*this);
}