summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-17 18:19:41 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-17 18:19:41 +0000
commit907508b25f91d7a34919839d9fb0f4bf10080b68 (patch)
treee6d84f200d390effabe23dac78d0448ef09abf42 /numeric.c
parent66bef9d238a415c9ccfed8a96c0e214fcbe454f3 (diff)
Integer#{any|all|no}_bits: Fix coercion. Add specs [#12753]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/numeric.c b/numeric.c
index 93098971fe..918b46e9d3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3175,6 +3175,7 @@ int_even_p(VALUE num)
static VALUE
int_allbits_p(VALUE num, VALUE mask)
{
+ mask = rb_to_int(mask);
return rb_int_equal(rb_int_and(num, mask), mask);
}
@@ -3188,6 +3189,7 @@ int_allbits_p(VALUE num, VALUE mask)
static VALUE
int_anybits_p(VALUE num, VALUE mask)
{
+ mask = rb_to_int(mask);
return num_zero_p(rb_int_and(num, mask)) ? Qfalse : Qtrue;
}
@@ -3201,6 +3203,7 @@ int_anybits_p(VALUE num, VALUE mask)
static VALUE
int_nobits_p(VALUE num, VALUE mask)
{
+ mask = rb_to_int(mask);
return num_zero_p(rb_int_and(num, mask));
}