# Bignum#odd?, Bignum#even? (for trunk)

e\$B:XF#\$H?=\$7\$^\$9!#e(B

e\$B\$I\$&\$;\$J\$i!"\$H;W\$C\$Fe(BBignum#odd?,
Bignum#even?e\$B\$bIU\$1B-\$7\$^\$7\$?!#e(B
e\$B<j85\$G\$Oe(B3e\$BG<eB.\$/\$J\$k\$h\$&\$G\$9!#e(B

# Index: bignum.c

— bignum.c (revision 13949)
+++ bignum.c (working copy)
@@ -2432,6 +2432,38 @@
}

/*

• call-seq:
• ``````big.odd? -> true or false
``````
• Returns `true` if big is an odd number.
• */

+static VALUE
+rb_big_odd_p(VALUE num)
+{

• if (BDIGITS(num)[0] & 1) {
• ``````  return Qtrue;
``````
• }
• return Qfalse;
+}

+/*

• call-seq:
• ``````big.even? -> true or false
``````
• Returns `true` if big is an even number.
• */

+static VALUE
+rb_big_even_p(VALUE num)
+{

• if (BDIGITS(num)[0] & 1) {
• ``````  return Qfalse;
``````
• }
• return Qtrue;
+}

+/*

• Bignum objects hold integers outside the range of
• Fixnum. Bignum objects are created
• automatically when integer calculations would otherwise overflow a
@@ -2484,6 +2516,8 @@
rb_define_method(rb_cBignum, “to_f”, rb_big_to_f, 0);
rb_define_method(rb_cBignum, “abs”, rb_big_abs, 0);
rb_define_method(rb_cBignum, “size”, rb_big_size, 0);
• rb_define_method(rb_cBignum, “odd?”, rb_big_odd_p, 0);

• rb_define_method(rb_cBignum, “even?”, rb_big_even_p, 0);

power_cache_init();
}