From: Rick DeNatale Date: 2006-10-26T08:26:47+09:00 Subject: Re: simple math question On 10/25/06, Brad Tilley wrote: > What's the quickest way to determine if an int is an even number > 2,4,6,8... > Anything such as int.even or int.odd returning true/false? I want to > test the length of an array and add one element to it if it has an odd > number of elements. > > Thank you! Integer#[n] returns a 1 or 0 corresponding to bit n, with n=0 being the least significant bit. so Even: an_int[0].zero? Odd: an_int[0].nonzero? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/