summaryrefslogtreecommitdiff
path: root/internal.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-13 05:36:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-13 05:36:33 +0000
commitf830ace8a831a954db7a6aae280a530651a5b58a (patch)
treefb2112fdd586672358bcf53f45b8532fde3297b7 /internal.h
parent235e7738d6371c1e3ca638e873acf663e7b90850 (diff)
object.c: rb_num_to_dbl
* object.c (rb_num_to_dbl): move from num2dbl_with_to_f in math.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
-rw-r--r--internal.h47
1 files changed, 29 insertions, 18 deletions
diff --git a/internal.h b/internal.h
index 59526c8ec7..a1eadfa074 100644
--- a/internal.h
+++ b/internal.h
@@ -903,31 +903,41 @@ VALUE rb_dbl_hash(double d);
#endif
static inline double
-rb_float_value_inline(VALUE v)
+rb_float_flonum_value(VALUE v)
{
#if USE_FLONUM
- if (FLONUM_P(v)) {
- if (v != (VALUE)0x8000000000000002) { /* LIKELY */
- union {
- double d;
- VALUE v;
- } t;
-
- VALUE b63 = (v >> 63);
- /* e: xx1... -> 011... */
- /* xx0... -> 100... */
- /* ^b63 */
- t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~0x03), 3);
- return t.d;
- }
- else {
- return 0.0;
- }
+ if (v != (VALUE)0x8000000000000002) { /* LIKELY */
+ union {
+ double d;
+ VALUE v;
+ } t;
+
+ VALUE b63 = (v >> 63);
+ /* e: xx1... -> 011... */
+ /* xx0... -> 100... */
+ /* ^b63 */
+ t.v = RUBY_BIT_ROTR((2 - b63) | (v & ~0x03), 3);
+ return t.d;
}
#endif
+ return 0.0;
+}
+
+static inline double
+rb_float_noflonum_value(VALUE v)
+{
return ((struct RFloat *)v)->float_value;
}
+static inline double
+rb_float_value_inline(VALUE v)
+{
+ if (FLONUM_P(v)) {
+ return rb_float_flonum_value(v);
+ }
+ return rb_float_noflonum_value(v);
+}
+
static inline VALUE
rb_float_new_inline(double d)
{
@@ -965,6 +975,7 @@ rb_float_new_inline(double d)
void rb_obj_copy_ivar(VALUE dest, VALUE obj);
VALUE rb_obj_equal(VALUE obj1, VALUE obj2);
VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
+double rb_num_to_dbl(VALUE val);
struct RBasicRaw {
VALUE flags;