Skip to content

Commit

Permalink
Use mrb_float instead of double
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Nov 19, 2016
1 parent a2fbd80 commit 22390aa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mrbgems/mruby-range-ext/src/range.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ mrb_range_size(mrb_state *mrb, mrb_value range)
{
struct RRange *r = mrb_range_ptr(range);
mrb_value beg, end;
double beg_f, end_f;
mrb_float beg_f, end_f;
mrb_bool num_p = TRUE;
mrb_bool excl;

beg = r->edges->beg;
end = r->edges->end;
excl = r->excl;
if (mrb_fixnum_p(beg)) {
beg_f = (double)mrb_fixnum(beg);
beg_f = (mrb_float)mrb_fixnum(beg);
}
else if (mrb_float_p(beg)) {
beg_f = mrb_float(beg);
Expand All @@ -156,7 +156,7 @@ mrb_range_size(mrb_state *mrb, mrb_value range)
num_p = FALSE;
}
if (mrb_fixnum_p(end)) {
end_f = (double)mrb_fixnum(end);
end_f = (mrb_float)mrb_fixnum(end);
}
else if (mrb_float_p(end)) {
end_f = mrb_float(end);
Expand All @@ -165,8 +165,8 @@ mrb_range_size(mrb_state *mrb, mrb_value range)
num_p = FALSE;
}
if (num_p) {
double n = end_f - beg_f;
double err = (fabs(beg_f) + fabs(end_f) + fabs(end_f-beg_f)) * DBL_EPSILON;
mrb_float n = end_f - beg_f;
mrb_float err = (fabs(beg_f) + fabs(end_f) + fabs(end_f-beg_f)) * DBL_EPSILON;

if (err>0.5) err=0.5;
if (excl) {
Expand Down

0 comments on commit 22390aa

Please sign in to comment.