DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦c2921e172⟧ TextFile

    Length: 377 (0x179)
    Types: TextFile
    Notes: UNIX file
    Names: »spow.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libmp/spow.c« 

TextFile

#include "mprec.h"


/*
 *	Spow sets "b" to "a" raised to the "n" power.  Note that
 *	a = b is acceptable.
 */

void
spow(a, n, b)
register mint	*a, *b;
register unsigned n;
{
	mint	ac;

	minit(&ac);
	mcopy(a, &ac);
	mcopy(mone, b);
	if (n != 0) {
		for (; n != 1; n >>= 1, mult(&ac, &ac, &ac))
			if (n % 2 != 0)
				mult(&ac, b, b);
		mult(&ac, b, b);
	}
	mpfree(ac.val);
}