File:  [MW Coherent from dump] / coherent / d / usr / lib / libmp / mitom.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:38 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 *	Mitom sets the mint pointed to by "mp" to have a value equal
 *	to the int "n".
 */
#include "mprec.h"
void
mitom(n, mp)
int	n;
mint	*mp;
{
	register char *rp, *limit, *value;
	unsigned an;
	char mifl;	/* minus flag */
	char tev[NORSIZ];	/* temporary for converted value */

	mpfree(mp->val);
	an = ((mifl = n<0) ? -n : n);
	rp = tev;
	while (an != 0) {
		*rp++ = an % BASE;
		an >>= L2BASE;
	}
	*rp++ = 0;
	limit = rp;
	if (mifl) {
		rp = tev - 1;
		while (++rp < limit)
			*rp = NEFL - *rp;
		++*tev;
	}
	value = (char *)mpalc(limit - tev);
	mp->val = value;
	mp->len = limit - tev;
	rp = tev;
	while (rp < limit)
		*value++ = *rp++;
	norm(mp);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.