|
|
1.1 root 1: #include "mp.h"
2:
3: mint
4: madd(a,b)
5: mint a,b;
6: {
7: mint x;
8: int i;
9:
10: x.low = a.low + b.low;
11: x.high = a.high + b.high;
12: if(x.low > e16){
13: x.low -= e16;
14: x.high += 1.;
15: }else
16: if(x.low < -e16){
17: x.low += e16;
18: x.high -= 1.;
19: }
20: if(x.high >= e16) ofl("madd");
21: if((x.high>0) && (x.low<0)){
22: x.high -= 1.;
23: x.low += e16;
24: }
25: if((x.high<0) && (x.low>0)){
26: x.high += 1.;
27: x.low -= e16;
28: }
29: return(x);
30: }
31:
32: mint
33: msub(a,b)
34: mint a,b;
35: {
36: b.high = -b.high;
37: b.low = -b.low;
38: return(madd(a,b));
39: }
40:
41: int
42: mcmp(a,b)
43: mint a, b;
44: {
45: if(a.high > b.high)
46: return(1);
47: if(a.high < b.high)
48: return(-1);
49: if(a.low > b.low)
50: return(1);
51: if(a.low < b.low)
52: return(-1);
53: return(0);
54: }
55:
56:
57: mint
58: itom(i)
59: int i;
60: {
61: mint x;
62:
63: x.high = 0.;
64: x.low = i;
65: return(x);
66: }
67: mint
68: mchs(a)
69: mint a;
70: {
71: a.high = -a.high;
72: a.low = -a.low;
73: return(a);
74: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.