31 |
|
|
32 |
|
|
33 |
long |
long |
34 |
fixint(x) |
fixint(object x) |
|
object x; |
|
35 |
{ |
{ |
36 |
if (type_of(x) != t_fixnum) |
if (type_of(x) != t_fixnum) |
37 |
FEerror("~S is not a fixnum.", 1, x); |
FEerror("~S is not a fixnum.", 1, x); |
39 |
} |
} |
40 |
|
|
41 |
int |
int |
42 |
fixnnint(x) |
fixnnint(object x) |
|
object x; |
|
43 |
{ |
{ |
44 |
if (type_of(x) != t_fixnum || fix(x) < 0) |
if (type_of(x) != t_fixnum || fix(x) < 0) |
45 |
FEerror("~S is not a non-negative fixnum.", 1, x); |
FEerror("~S is not a non-negative fixnum.", 1, x); |
75 |
|
|
76 |
|
|
77 |
object |
object |
78 |
make_fixnum(i) |
make_fixnum(long i) |
|
int i; |
|
79 |
{ |
{ |
80 |
object x; |
object x; |
81 |
|
|
95 |
} |
} |
96 |
|
|
97 |
object |
object |
98 |
make_ratio(num, den) |
make_ratio(object num, object den) |
|
object num, den; |
|
99 |
{ |
{ |
100 |
object g, r, integer_divide1(), get_gcd(); |
object g, r, integer_divide1(object x, object y), get_gcd(object x, object y); |
101 |
vs_mark; |
vs_mark; |
102 |
|
|
103 |
if (number_zerop(den)) |
if (number_zerop(den)) |
135 |
} |
} |
136 |
|
|
137 |
object |
object |
138 |
make_shortfloat(f) |
make_shortfloat(double f) |
|
|
|
|
double f; |
|
139 |
{ |
{ |
140 |
object x; |
object x; |
141 |
|
|
147 |
} |
} |
148 |
|
|
149 |
object |
object |
150 |
make_longfloat(f) |
make_longfloat(longfloat f) |
|
longfloat f; |
|
151 |
{ |
{ |
152 |
object x; |
object x; |
153 |
|
|
159 |
} |
} |
160 |
|
|
161 |
object |
object |
162 |
make_complex(r, i) |
make_complex(object r, object i) |
|
object r, i; |
|
163 |
{ |
{ |
164 |
object c; |
object c; |
165 |
vs_mark; |
vs_mark; |
181 |
r = make_longfloat(number_to_double(r)); |
r = make_longfloat(number_to_double(r)); |
182 |
vs_push(r); |
vs_push(r); |
183 |
break; |
break; |
184 |
|
default: |
185 |
|
break; |
186 |
} |
} |
187 |
break; |
break; |
188 |
case t_shortfloat: |
case t_shortfloat: |
197 |
r = make_longfloat((double)(sf(r))); |
r = make_longfloat((double)(sf(r))); |
198 |
vs_push(r); |
vs_push(r); |
199 |
break; |
break; |
200 |
|
default: |
201 |
|
break; |
202 |
} |
} |
203 |
break; |
break; |
204 |
case t_longfloat: |
case t_longfloat: |
210 |
i = make_longfloat(number_to_double(i)); |
i = make_longfloat(number_to_double(i)); |
211 |
vs_push(i); |
vs_push(i); |
212 |
break; |
break; |
213 |
|
default: |
214 |
|
break; |
215 |
} |
} |
216 |
break; |
break; |
217 |
|
default: |
218 |
|
break; |
219 |
} |
} |
220 |
c = alloc_object(t_complex); |
c = alloc_object(t_complex); |
221 |
c->cmp.cmp_real = r; |
c->cmp.cmp_real = r; |
225 |
} |
} |
226 |
|
|
227 |
double |
double |
228 |
number_to_double(x) |
number_to_double(object x) |
|
object x; |
|
229 |
{ |
{ |
230 |
switch(type_of(x)) { |
switch(type_of(x)) { |
231 |
case t_fixnum: |
case t_fixnum: |
232 |
return((double)(fix(x))); |
return((double)(fix(x))); |
233 |
|
|
234 |
case t_bignum: |
case t_bignum: |
235 |
return(big_to_double((struct bignum *)x)); |
return(big_to_double(/* (struct bignum *) */x)); |
236 |
|
|
237 |
case t_ratio: |
case t_ratio: |
238 |
return(number_to_double(x->rat.rat_num) / |
return(number_to_double(x->rat.rat_num) / |
246 |
|
|
247 |
default: |
default: |
248 |
wrong_type_argument(TSor_rational_float, x); |
wrong_type_argument(TSor_rational_float, x); |
249 |
|
return(0.0); |
250 |
} |
} |
251 |
} |
} |
252 |
|
|
253 |
init_number() |
void |
254 |
|
init_number(void) |
255 |
{ |
{ |
256 |
int i; |
int i; |
|
object x; |
|
257 |
|
|
258 |
for (i = -SMALL_FIXNUM_LIMIT; i < SMALL_FIXNUM_LIMIT; i++) { |
for (i = -SMALL_FIXNUM_LIMIT; i < SMALL_FIXNUM_LIMIT; i++) { |
259 |
small_fixnum_table[i + SMALL_FIXNUM_LIMIT].t |
small_fixnum_table[i + SMALL_FIXNUM_LIMIT].t |