Commit 72ed7eeb authored by Tomasz Dąbrowski's avatar Tomasz Dąbrowski

Fixed Range.size to use proper floating point tolerance

parent a8b8abbd
...@@ -64,6 +64,13 @@ ...@@ -64,6 +64,13 @@
#endif #endif
#include "mrbconf.h" #include "mrbconf.h"
#ifdef MRB_USE_FLOAT
#define MRB_FLOAT_EPSILON FLT_EPSILON
#else
#define MRB_FLOAT_EPSILON DBL_EPSILON
#endif
#include "mruby/common.h" #include "mruby/common.h"
#include <mruby/value.h> #include <mruby/value.h>
#include <mruby/gc.h> #include <mruby/gc.h>
......
...@@ -140,7 +140,7 @@ mrb_range_size(mrb_state *mrb, mrb_value range) ...@@ -140,7 +140,7 @@ mrb_range_size(mrb_state *mrb, mrb_value range)
} }
if (num_p) { if (num_p) {
mrb_float n = end_f - beg_f; mrb_float n = end_f - beg_f;
mrb_float err = (fabs(beg_f) + fabs(end_f) + fabs(end_f-beg_f)) * DBL_EPSILON; mrb_float err = (fabs(beg_f) + fabs(end_f) + fabs(end_f-beg_f)) * MRB_FLOAT_EPSILON;
if (err>0.5) err=0.5; if (err>0.5) err=0.5;
if (excl) { if (excl) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment