示例#1
0
void 
showanswer(struct unittype * have, struct unittype * want)
{
	if (compareunits(have, want)) {
		printf("conformability error\n");
		showunit(have);
		showunit(want);
	}
	else if (have->offset != want->offset) {
		if (want->quantity)
			printf("WARNING: conversion of non-proportional quantities.\n");
		printf("\t");
		if (have->quantity)
			printf("%.8g\n",
			    (have->factor + have->offset-want->offset)/want->factor);
		else
			printf(" (-> x*%.8g %+.8g)\n\t (<- y*%.8g %+.8g)\n",
			    have->factor / want->factor,
			    (have->offset-want->offset)/want->factor,
			    want->factor / have->factor,
			    (want->offset - have->offset)/have->factor);
	}
	else
		printf("\t* %.8g\n\t/ %.8g\n", have->factor / want->factor,
		    want->factor / have->factor);
}
示例#2
0
文件: units.c 项目: ajinkya93/OpenBSD
void
showanswer(struct unittype *have, struct unittype *want)
{
	if (compareunits(have, want)) {
		printf("conformability error\n");
		showunit(have);
		showunit(want);
	} else
		printf("\t* %.8g\n\t/ %.8g\n", have->factor / want->factor,
		    want->factor / have->factor);
}
示例#3
0
文件: units.c 项目: Hooman3/minix
static void
showanswer(struct unittype * have, struct unittype * want)
{
	if (compareunits(have, want)) {
		if (compareunitsreciprocal(have, want)) {
			printf("conformability error\n");
			showunit(have);
			showunit(want);
		} else {
			printf("\treciprocal conversion\n");
			printf("\t* %.*g\n\t/ %.*g\n",
			    precision, 1 / (have->factor * want->factor),
			    precision, want->factor * have->factor);
		}
	}
	else
		printf("\t* %.*g\n\t/ %.*g\n",
		    precision, have->factor / want->factor,
		    precision, want->factor / have->factor);
}