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

**URL:** <https://www.ruby-forum.com/t/bignum-odd-bignum-even-for-trunk/120395>\
**Category:** Development\
**Created:** [November 16, 2007, 2:56pm UTC](https://www.ruby-forum.com/t/bignum-odd-bignum-even-for-trunk/120395 "2007-11-16T14:56:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sugie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@sugie](https://www.ruby-forum.com/u/sugie)\
**Post date:** [November 16, 2007, 2:56pm UTC](https://www.ruby-forum.com/t/bignum-odd-bignum-even-for-trunk/120395/1 "2007-11-16T14:56:37Z")

</div>

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);
