1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
#include "lie.h"
static object
bin_abs_bin(a)
object a;
{
object result;
result = (object) copybigint((bigint*) a, (bigint*) NULL);
result->b.size = abs(result->b.size);
return (result);
}
static object
bin_min_bin(a)
object a;
{
object result;
if (isshared(a))
result = (object) copybigint((bigint*) a, NULL);
else
result = a;
result->b.size = -result->b.size;
return (result);
}
static object
int_lt_bin_bin(a, b)
object a, b;
{
boolean crit = (cmp((bigint*) a,(bigint*) b) < 0);
freemem(a);freemem(b);
if (crit)
return (object) bool_true;
return (object) bool_false;
}
static object
int_gt_bin_bin(a, b)
object a, b;
{
boolean crit = (cmp((bigint*) a,(bigint*) b) > 0);
freemem(a);freemem(b);
if (crit)
return (object) bool_true;
return (object) bool_false;
}
static object
int_le_bin_bin(a, b)
object a, b;
{
boolean crit = (cmp((bigint*) a,(bigint*) b) <= 0);
freemem(a);
freemem(b);
if (crit)
return (object) bool_true;
return (object) bool_false;
}
static object
int_ge_bin_bin(a, b)
object a, b;
{
boolean crit = (cmp((bigint*) a,(bigint*) b) >= 0);
freemem(a);freemem(b);
if (crit)
return (object) bool_true;
return (object) bool_false;
}
static object
int_eq_bin_bin(a, b)
object a, b;
{
boolean crit = cmp((bigint*) a,(bigint*) b);
freemem(a); freemem(b);
if (!crit)
return (object) bool_true;
return (object) bool_false;
}
static object
int_ne_bin_bin(a, b)
object a, b;
{
boolean crit = cmp((bigint*) a,(bigint*) b);
freemem(a); freemem(b);
if (crit)
return (object) bool_true;
return (object) bool_false;
}
static object bin_add_bin_bin(a,b)
object a,b;
{
return (object) add((bigint*) a , (bigint*) b);
}
static object bin_sub_bin_bin(a,b)
object a,b;
{
return (object) sub((bigint*) a , (bigint*) b);
}
static object
bin_mul_bin_bin(a,b)
object a,b;
{
return (object) mult((bigint*) a,(bigint*) b);
}
static object
bin_div_bin_bin(a,b)
object a,b;
{
return (object) quotient((bigint*) a,(bigint*) b);
}
static object
bin_mod_bin_bin(a,b)
object a,b;
{
return (object) mod((bigint*) a,(bigint*) b);
}
static object addupdate_bin_bin(a,b)
object a,b ;
{
bigint* c,* d,* result;
setshared(a);
if (type_of(a) == INTEGER) c = (*int2bin)(&a->i);
else c = (bigint*) a;
if (type_of(b) == INTEGER) d = (*int2bin)(&b->i);
else d = (bigint*) b;
result = add(c,d);
clrshared(a);
return (object) result;
}
static object
vid_addupdate_bin_bin(list)
symblst list;
{return inside_vid_assign(list,true,addupdate_bin_bin);}
#ifdef development
static object bin_addc_bin_int(a,b)
bigint *a; intcel *b;
{
addc(&a,b->intval);
return (object) a;
}
static object bin_mulc_bin_int(a,b)
bigint *a; intcel *b;
{
mulc(&a,b->intval);
return (object) a;
}
static object bin_divc_bin_int(a,b)
bigint *a; intcel *b;
{
divc(&a,b->intval);
return (object) a;
}
#endif
Symbrec static7[] = {
C1("abs", bin_abs_bin, BIGINT, BIGINT)
C1("-", bin_min_bin, BIGINT, BIGINT)
C2("==", int_eq_bin_bin, INTEGER, BIGINT, BIGINT)
C2("!=", int_ne_bin_bin, INTEGER, BIGINT, BIGINT)
C2("<=", int_le_bin_bin, INTEGER, BIGINT, BIGINT)
C2(">=", int_ge_bin_bin, INTEGER, BIGINT, BIGINT)
C2("<", int_lt_bin_bin, INTEGER, BIGINT, BIGINT)
C2(">", int_gt_bin_bin, INTEGER, BIGINT, BIGINT)
C2("+", bin_add_bin_bin, BIGINT, BIGINT, BIGINT)
C2("-", bin_sub_bin_bin, BIGINT, BIGINT, BIGINT)
C2("*",bin_mul_bin_bin,BIGINT,BIGINT,BIGINT)
C2("/",bin_div_bin_bin,BIGINT,BIGINT,BIGINT)
C2("%",bin_mod_bin_bin,BIGINT,BIGINT,BIGINT)
M2(".+=",vid_addupdate_bin_bin, VOID,BIGINT,BIGINT)
#ifdef development
C2("addc",bin_addc_bin_int, BIGINT, BIGINT, INTEGER)
C2("mulc",bin_mulc_bin_int, BIGINT, BIGINT, INTEGER)
C2("divc",bin_divc_bin_int, BIGINT, BIGINT, INTEGER)
#endif
};
int nstatic7 = array_size(static7);
|