100 |
|
|
101 |
object r; |
object r; |
102 |
|
|
103 |
if (y==small_fixnum(1)) |
if (y==small_fixnum(1) || x==small_fixnum(0)) |
104 |
return x; |
return x; |
105 |
|
|
106 |
if (type_of(y)==t_fixnum && type_of(x)==t_fixnum) |
if (type_of(y)==t_fixnum && type_of(x)==t_fixnum) |
120 |
static object |
static object |
121 |
ratio_op_with_cancellation(object a,object b,object c,object d,object (*op)(object,object)) { |
ratio_op_with_cancellation(object a,object b,object c,object d,object (*op)(object,object)) { |
122 |
|
|
123 |
object b0,d0,g,t,g1,r; |
object b0,d0,g,t,g1; |
124 |
|
|
125 |
b0=b; |
b0=b; |
126 |
d0=d; |
d0=d; |
139 |
|
|
140 |
b=number_times(b,d); |
b=number_times(b,d); |
141 |
|
|
142 |
r=alloc_object(t_ratio); |
return make_ratio(t,b,1); |
|
r->rat.rat_num=t; |
|
|
r->rat.rat_den=b; |
|
|
|
|
|
return r; |
|
143 |
|
|
144 |
} |
} |
145 |
|
|
147 |
static object |
static object |
148 |
ratio_mult_with_cancellation(object a,object b,object c,object d) { |
ratio_mult_with_cancellation(object a,object b,object c,object d) { |
149 |
|
|
150 |
object g,r; |
object g; |
151 |
|
|
152 |
g=get_gcd(a,d); |
g=get_gcd(a,d); |
153 |
|
|
159 |
b=integer_exact_quotient(b,g,0); |
b=integer_exact_quotient(b,g,0); |
160 |
c=integer_exact_quotient(c,g,0); |
c=integer_exact_quotient(c,g,0); |
161 |
|
|
162 |
r=alloc_object(t_ratio); |
a=number_times(a,c); |
163 |
r->rat.rat_num=number_times(a,c); |
b=number_times(b,d); |
|
r->rat.rat_den=number_times(b,d); |
|
164 |
|
|
165 |
return r; |
return make_ratio(a,b,1); |
166 |
|
|
167 |
} |
} |
168 |
|
|
739 |
switch (type_of(y)) { |
switch (type_of(y)) { |
740 |
case t_fixnum: |
case t_fixnum: |
741 |
case t_bignum: |
case t_bignum: |
742 |
if(number_zerop(y) == TRUE) |
/* if(number_zerop(y) == TRUE) */ |
743 |
zero_divisor(); |
/* zero_divisor(); */ |
744 |
if (number_minusp(y) == TRUE) { |
/* if (number_minusp(y) == TRUE) { */ |
745 |
x = number_negate(x); |
/* x = number_negate(x); */ |
746 |
y = number_negate(y); |
/* y = number_negate(y); */ |
747 |
} |
/* } */ |
748 |
z = make_ratio(x, y); |
/* z = make_ratio(x, y, 0); */ |
749 |
return(z); |
return(make_ratio(x, y, 0)); |
750 |
case t_ratio: |
case t_ratio: |
751 |
if(number_zerop(y->rat.rat_num)) |
if(number_zerop(y->rat.rat_num)) |
752 |
zero_divisor(); |
zero_divisor(); |