summaryrefslogtreecommitdiffhomepage
path: root/mrbgems
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-03-28 08:33:50 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-03-28 08:35:29 +0900
commita5244b02c5cd5031d59bc59e7182e69f00cbfade (patch)
tree118a0bfdb00a8e0bad051674500a6d9f564d6f6a /mrbgems
parentc2f929ad0f9c4b98cd4b8027052cbb3af599f19b (diff)
downloadmruby-a5244b02c5cd5031d59bc59e7182e69f00cbfade.tar.gz
mruby-a5244b02c5cd5031d59bc59e7182e69f00cbfade.zip
numeric.c: function renaming.
- `mrb_num_div_int(mrb,x,y)` -> `mrb_div_int(mrb,x,y)` - `mrb_num_div_flo(mrb,x,y)` -> `mrb_div_flo(x,y)` They are internal function not supposed to be used outside of the core.
Diffstat (limited to 'mrbgems')
-rw-r--r--mrbgems/mruby-complex/src/complex.c19
-rw-r--r--mrbgems/mruby-rational/src/rational.c21
2 files changed, 19 insertions, 21 deletions
diff --git a/mrbgems/mruby-complex/src/complex.c b/mrbgems/mruby-complex/src/complex.c
index c5f4d7faf..0bf5377ed 100644
--- a/mrbgems/mruby-complex/src/complex.c
+++ b/mrbgems/mruby-complex/src/complex.c
@@ -236,8 +236,7 @@ complex_mul(mrb_state *mrb, mrb_value x)
}
#ifndef MRB_NO_FLOAT
-mrb_float mrb_num_div_flo(mrb_state*, mrb_float, mrb_float);
-#define div_flo(x,y) mrb_num_div_flo(NULL, x, y)
+mrb_float mrb_div_flo(mrb_float, mrb_float);
#endif
/* Arithmetic on (significand, exponent) pairs avoids premature overflow in
@@ -276,7 +275,7 @@ static void
div_pair(struct float_pair *q, struct float_pair const *a,
struct float_pair const *b)
{
- q->s = div_flo(a->s, b->s);
+ q->s = mrb_div_flo(a->s, b->s);
q->x = a->x - b->x;
}
@@ -289,7 +288,7 @@ complex_div(mrb_state *mrb, mrb_value self)
a = complex_ptr(mrb, self);
if (mrb_type(rhs) != MRB_TT_COMPLEX) {
mrb_float f = mrb_to_flo(mrb, rhs);
- return complex_new(mrb, div_flo(a->real, f), div_flo(a->imaginary, f));
+ return complex_new(mrb, mrb_div_flo(a->real, f), mrb_div_flo(a->imaginary, f));
}
struct float_pair ar, ai, br, bi;
@@ -332,7 +331,7 @@ complex_div(mrb_state *mrb, mrb_value self)
return complex_new(mrb, F(ldexp)(zr.s, zr.x), F(ldexp)(zi.s, zi.x));
}
-mrb_int mrb_num_div_int(mrb_state *mrb, mrb_int x, mrb_int y);
+mrb_int mrb_div_int(mrb_state *mrb, mrb_int x, mrb_int y);
mrb_value mrb_rational_new(mrb_state *mrb, mrb_int n, mrb_int d);
mrb_value mrb_rational_div(mrb_state *mrb, mrb_value x);
@@ -347,7 +346,7 @@ cpx_int_div(mrb_state *mrb, mrb_value x)
mrb_int a = mrb_integer(x);
if (mrb_integer_p(y)) {
- mrb_int div = mrb_num_div_int(mrb, a, mrb_integer(y));
+ mrb_int div = mrb_div_int(mrb, a, mrb_integer(y));
return mrb_int_value(mrb, div);
}
switch (mrb_type(y)) {
@@ -359,7 +358,7 @@ cpx_int_div(mrb_state *mrb, mrb_value x)
x = complex_new(mrb, (mrb_float)a, 0);
return complex_div(mrb, x);
default:
- return mrb_float_value(mrb, div_flo((mrb_float)a, mrb_to_flo(mrb, y)));
+ return mrb_float_value(mrb, mrb_div_flo((mrb_float)a, mrb_to_flo(mrb, y)));
}
}
@@ -384,7 +383,7 @@ cpx_int_quo(mrb_state *mrb, mrb_value x)
x = complex_new(mrb, (mrb_float)a, 0);
return complex_div(mrb, x);
default:
- return mrb_float_value(mrb, div_flo((mrb_float)a, mrb_to_flo(mrb, y)));
+ return mrb_float_value(mrb, mrb_div_flo((mrb_float)a, mrb_to_flo(mrb, y)));
}
}
@@ -398,10 +397,10 @@ cpx_flo_div(mrb_state *mrb, mrb_value x)
case MRB_TT_COMPLEX:
return complex_div(mrb, complex_new(mrb, a, 0));
case MRB_TT_FLOAT:
- a = div_flo(a, mrb_float(y));
+ a = mrb_div_flo(a, mrb_float(y));
return mrb_float_value(mrb, a);
default:
- a = div_flo(a, mrb_to_flo(mrb, y));
+ a = mrb_div_flo(a, mrb_to_flo(mrb, y));
return mrb_float_value(mrb, a);
}
}
diff --git a/mrbgems/mruby-rational/src/rational.c b/mrbgems/mruby-rational/src/rational.c
index c08503d0e..1d53afb5c 100644
--- a/mrbgems/mruby-rational/src/rational.c
+++ b/mrbgems/mruby-rational/src/rational.c
@@ -484,7 +484,7 @@ rational_minus(mrb_state *mrb, mrb_value x)
}
#ifndef MRB_NO_FLOAT
-mrb_float mrb_num_div_flo(mrb_state*, mrb_float, mrb_float);
+mrb_float mrb_div_flo(mrb_float, mrb_float);
#endif
static mrb_value
@@ -517,7 +517,7 @@ rational_add(mrb_state *mrb, mrb_value x)
case MRB_TT_FLOAT:
{
mrb_float z = p1->numerator + mrb_float(y) * p1->denominator;
- return mrb_float_value(mrb, mrb_num_div_flo(mrb, z, (mrb_float)p1->denominator));
+ return mrb_float_value(mrb, mrb_div_flo(z, (mrb_float)p1->denominator));
}
#endif
@@ -563,7 +563,7 @@ rational_sub(mrb_state *mrb, mrb_value x)
default:
{
mrb_float z = p1->numerator - mrb_to_flo(mrb, y) * p1->denominator;
- return mrb_float_value(mrb, mrb_num_div_flo(mrb, z, (mrb_float)p1->denominator));
+ return mrb_float_value(mrb, mrb_div_flo(z, (mrb_float)p1->denominator));
}
#else
default:
@@ -599,7 +599,7 @@ rational_mul(mrb_state *mrb, mrb_value x)
case MRB_TT_FLOAT:
{
mrb_float z = p1->numerator * mrb_float(y);
- return mrb_float_value(mrb, mrb_num_div_flo(mrb, z, (mrb_float)p1->denominator));
+ return mrb_float_value(mrb, mrb_div_flo(z, (mrb_float)p1->denominator));
}
#endif
@@ -608,8 +608,6 @@ rational_mul(mrb_state *mrb, mrb_value x)
}
}
-mrb_int mrb_num_div_int(mrb_state *, mrb_int, mrb_int);
-
mrb_value
mrb_rational_div(mrb_state *mrb, mrb_value x)
{
@@ -643,8 +641,8 @@ mrb_rational_div(mrb_state *mrb, mrb_value x)
#ifndef MRB_NO_FLOAT
case MRB_TT_FLOAT:
{
- mrb_float z = mrb_num_div_flo(mrb, p1->numerator, mrb_to_flo(mrb, y));
- return mrb_float_value(mrb, mrb_num_div_flo(mrb, z, (mrb_float)p1->denominator));
+ mrb_float z = mrb_div_flo(p1->numerator, mrb_to_flo(mrb, y));
+ return mrb_float_value(mrb, mrb_div_flo(z, (mrb_float)p1->denominator));
}
#else
mrb_raise(mrb, E_TYPE_ERROR, "non integer division");
@@ -653,6 +651,7 @@ mrb_rational_div(mrb_state *mrb, mrb_value x)
}
#define rational_div mrb_rational_div
+mrb_int mrb_div_int(mrb_state *, mrb_int, mrb_int);
#ifndef MRB_USE_COMPLEX
/* 15.2.8.3.4 */
@@ -666,7 +665,7 @@ rat_int_div(mrb_state *mrb, mrb_value x)
mrb_int a = mrb_integer(x);
if (mrb_integer_p(y)) {
- mrb_int div = mrb_num_div_int(mrb, a, mrb_integer(y));
+ mrb_int div = mrb_div_int(mrb, a, mrb_integer(y));
return mrb_int_value(mrb, div);
}
switch (mrb_type(y)) {
@@ -677,7 +676,7 @@ rat_int_div(mrb_state *mrb, mrb_value x)
case MRB_TT_FLOAT:
mrb_raise(mrb, E_TYPE_ERROR, "non integer multiplication");
#else
- return mrb_float_value(mrb, mrb_num_div_flo(mrb, (mrb_float)a, mrb_to_flo(mrb, y)));
+ return mrb_float_value(mrb, mrb_div_flo((mrb_float)a, mrb_to_flo(mrb, y)));
#endif
}
}
@@ -704,7 +703,7 @@ rat_int_quo(mrb_state *mrb, mrb_value x)
#ifdef MRB_NO_FLOAT
mrb_raise(mrb, E_TYPE_ERROR, "non integer multiplication");
#else
- return mrb_float_value(mrb, mrb_num_div_flo(mrb, (mrb_float)a, mrb_to_flo(mrb, y)));
+ return mrb_float_value(mrb, mrb_div_flo((mrb_float)a, mrb_to_flo(mrb, y)));
#endif
}
}