/[gcl]/gcl/o/number.c
ViewVC logotype

Diff of /gcl/o/number.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by camm, Fri Jul 12 22:00:49 2002 UTC revision 1.4 by camm, Sat Jul 20 07:10:56 2002 UTC
# Line 31  Foundation, 675 Mass Ave, Cambridge, MA Line 31  Foundation, 675 Mass Ave, Cambridge, MA
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);
# Line 40  object x; Line 39  object 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);
# Line 77  DEFUN("ALLOCATE-BIGGER-FIXNUM-RANGE",obj Line 75  DEFUN("ALLOCATE-BIGGER-FIXNUM-RANGE",obj
75    
76    
77  object  object
78  make_fixnum(i)  make_fixnum(long i)
 int i;  
79  {  {
80          object x;          object x;
81    
# Line 98  int i; Line 95  int i;
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))
# Line 139  object num, den; Line 135  object num, den;
135  }  }
136    
137  object  object
138  make_shortfloat(f)  make_shortfloat(double f)
   
 double f;  
139  {  {
140          object x;          object x;
141    
# Line 153  double f; Line 147  double f;
147  }  }
148    
149  object  object
150  make_longfloat(f)  make_longfloat(longfloat f)
 longfloat f;  
151  {  {
152          object x;          object x;
153    
# Line 166  longfloat f; Line 159  longfloat f;
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;
# Line 189  object r, i; Line 181  object r, i;
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:
# Line 203  object r, i; Line 197  object r, i;
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:
# Line 214  object r, i; Line 210  object r, i;
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;
# Line 225  object r, i; Line 225  object r, i;
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) /
# Line 247  object x; Line 246  object x;
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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26