method
odd?
ruby latest stable - Class:
Integer
odd?()public
Returns true if int is an odd number.
VALUE
rb_int_odd_p(VALUE num)
{
if (FIXNUM_P(num)) {
if (num & 2) {
return Qtrue;
}
}
else if (RB_TYPE_P(num, T_BIGNUM)) {
return rb_big_odd_p(num);
}
else if (rb_funcall(num, '%', 1, INT2FIX(2)) != INT2FIX(0)) {
return Qtrue;
}
return Qfalse;
} Related methods
- Instance methods
- %
- &
- *
- **
- +
- -
- -@
- /
- <
- <<
- <=
- <=>
- ==
- ===
- >
- >=
- >>
- []
- ^
- abs
- allbits?
- anybits?
- bit_length
- ceil
- chr
- coerce
- dclone
- denominator
- digits
- div
- divmod
- downto
- even?
- fdiv
- floor
- gcd
- gcdlcm
- inspect
- integer?
- lcm
- magnitude
- modulo
- next
- nobits?
- numerator
- odd?
- ord
- pow
- pred
- prime?
- prime_division
- rationalize
- remainder
- round
- size
- succ
- times
- to_bn
- to_d
- to_f
- to_i
- to_int
- to_r
- to_s
- truncate
- upto
- |
- ~
- Class methods
- each_prime
- from_prime_division
- sqrt