Here is the lhmb.h source file. Clip and save.


/*
 * lhmb.h - long hand multiplication (binary version).
 *	Calculates ridiculously large powers of 13.
 *
 *	Scott Coburn  March 1992
 */

/*	power		POWER		# of chars
 *	-----		--------	----------
 *	 13^0		 1		 2
 *	 13^1		 13		 15 
 *	 13^2		 169		 189
 *	 13^3		 2197		 2448
 *	 13^4		 28561		 31816
 *	 13^5		 371293		 413600
 *	 13^6		 4826809	 5376792
 *	 13^7		 62748517	 69898294
 *	 13^8		 815730721	 908677814
 *
 * The '# of chars' column is calculated from the following formula:
 *
 *	13^n = 10^x	->	n log(13) = x log(10)
 *
 * So '# of chars' = POWER * log(13) rounded up to the next integer.
 */

/*
 *	BEFORE COMPILING...
 *
 * define POWER to be one of the #s from the POWER column above, then
 * define CHAR as the coresponding '# of chars'.  Then compile and run.
 * See lhmb.c for how to compile and run.
 */

#define BASE	13
#define POWER	62748517	/* power of BASE to calc		*/
#define CHAR	69898294	/* # of resulting chars			*/

#if USE64

	/* these values assume a 64 bit unsigned long long int	*/

#define MASK	(0xFFFFFFFF)	/* mask for lower 32 bits		*/
#define SHIFT	(32)		/* shift right to get upper 32 bits	*/
#define	CPW	(8)		/* decimal chars per 32 bit word	*/
#define DIVISOR	(100000000)	/* this is 10^CPW for bin to decimal	*/

#define	HFORMAT1 "%08x\n"	/* hex input/output format		*/
#define	HFORMAT2 "%llx"		/* hex input/output format		*/
#define	DFORMAT	 "%08lld\n"	/* decimal output format		*/

typedef unsigned long long int ULINT;	/* MUST be 64 bits...		*/
typedef unsigned long int USINT;	/* MUST be 32 bits...		*/

#else

	/* these values assume a 32 bit unsigned long int	*/

#define MASK	(0xFFFF)	/* mask for lower 16 bits		*/
#define SHIFT	(16)		/* shift right to get upper 16 bits	*/
#define	CPW	(4)		/* decimal chars per 16 bit word	*/
#define DIVISOR	(10000)		/* this is 10^CPW for bin to decimal	*/

#define	HFORMAT1 "%04x\n"	/* hex input/output format		*/
#define	HFORMAT2 "%x"		/* hex input/output format		*/
#define	DFORMAT	 "%04d\n"	/* decimal output format		*/

typedef unsigned long int ULINT;	/* MUST be 32 bits...		*/
typedef unsigned short int USINT;	/* MUST be 16 bits...		*/

#endif

#define SIZE	((CHAR/CPW)+1)	/* size of various arrays		*/

#ifndef TRUE
#define TRUE (1)
#endif
#ifndef FALSE
#define FALSE (0)
#endif