mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix FIXABLE_FLOAT() on MRB_INT64; ref #4566
Normal `TYPED_FIXABLE(f,mrb_float)` does not work on 64bit int from casting problems. The new approach works well, but assumes two's complement and IEEE-754 floating point numbers.
This commit is contained in:
@@ -23,8 +23,12 @@ MRB_BEGIN_DECL
|
||||
#define NEGFIXABLE(f) TYPED_NEGFIXABLE(f,mrb_int)
|
||||
#define FIXABLE(f) TYPED_FIXABLE(f,mrb_int)
|
||||
#ifndef MRB_WITHOUT_FLOAT
|
||||
#ifdef MRB_INT64
|
||||
#define FIXABLE_FLOAT(f) ((f)>=-9223372036854775808.0 && (f)<9223372036854775808.0)
|
||||
#else
|
||||
#define FIXABLE_FLOAT(f) TYPED_FIXABLE(f,mrb_float)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MRB_WITHOUT_FLOAT
|
||||
MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
|
||||
|
||||
Reference in New Issue
Block a user