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); }
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); }
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); }