|
|
1.1 root 1: /* (-lgl
2: * COHERENT Version 3.0
3: * Copyright (c) 1982, 1990 by Mark Williams Company.
4: * All rights reserved. May not be copied without permission.
5: -lgl) */
6: /*
7: * Definitions of all user multi-precision types, macros and
8: * not-int returning functions.
9: */
10:
11: #ifndef MPREC_H
12: #define MPREC_H MPREC_H
13:
14: #ifndef NULL
15: #define NULL ((char *)0)
16: #endif
17: #define TRUE (0 == 0)
18: #define FALSE (0 != 0)
19: #define BASE 128
20: #define L2BASE 7
21: #define NEFL (BASE - 1) /* leading byte of negative numbers */
22: #define NORSIZ 4 /* maximum size for int value */
23:
24:
25: /*
26: * Multi-precision integer type.
27: */
28:
29: typedef struct {
30: unsigned len;
31: char *val;
32: } mint;
33:
34:
35: /*
36: * Minit initializes a mint so that it may be used by the other
37: * multi-precision routines. This simply consists of setting the
38: * val field to NULL so that mpfree will know that there is nothing
39: * to free. Note that the mint so initialized has no value and
40: * should not be used as an operand, but may be used as the result
41: * of any of the multi-precision routines.
42: */
43:
44: #define minit(mp) (mp)->val = NULL
45:
46:
47: /*
48: * Mvfree frees the value associated to a pointer to a mint.
49: * Note that it does not re-initialize the mint.
50: */
51:
52: #define mvfree(mp) mpfree((mp)->val)
53:
54:
55: /*
56: * Functions returning non-ints.
57: */
58:
59: void gcd(), /* greatest common divisor of 2 mints */
60: madd(), /* add 2 mints */
61: mcopy(), /* copy mint */
62: mdiv(), /* divide 2 mints */
63: min(), /* read in mint from stdin */
64: mintfr(), /* free all space used by a mint */
65: mitom(), /* set a mint to the value of an int */
66: mneg(), /* negate a mint */
67: mout(), /* write out mint onto stdout */
68: mperr(), /* print error on stdout and exit */
69: mpfree(), /* free space allocated by mpalc */
70: msma(), /* shift-multiply-add inplace */
71: msqrt(), /* square root of mint */
72: msub(), /* subtract 2 mints */
73: mult(), /* multiply 2 mints */
74: norm(), /* normalize a mint */
75: pow(), /* raise mint to a mint power mod a mint */
76: rpow(), /* raise mint to a mint power */
77: sdiv(), /* divide a mint by a char */
78: smult(), /* multiply a mint by a char */
79: spow(), /* raise mint to an unsigned power */
80: xgcd(); /* extended greatest common divisor */
81: char *mpalc(), /* allocate space */
82: *mtos(); /* convert mint to string */
83: mint *itom(); /* allocate space for mint initialized to int */
84:
85:
86: /* external variables */
87:
88: extern mint *mzero, /* a mint which has a value of zero */
89: *mone, /* a mint which has a value of one */
90: *mminint, /* min value that fits in an int */
91: *mmaxint; /* max value that fits in an int */
92: extern int ibase, /* input base (2 <= ibase <= 16 assumed) */
93: obase; /* output base (2 <= obase <= 16 assumed) */
94:
95: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.