From: Corey Haines Date: 2007-12-18T07:41:21+09:00 Subject: Re: dividing by two and rounding up Why not get the arrays: irb(main):022:0> a => [1, 2, 3, 4, 5, 6] irb(main):023:0> a.slice(0,3) => [1, 2, 3] irb(main):024:0> a.slice(3,3) => [4, 5, 6] irb(main):025:0> b => [1, 2, 3, 4, 5] irb(main):026:0> b.slice(0,3) => [1, 2, 3] irb(main):027:0> b.slice(3,3) => [4, 5] then loop over them creating the columns. -corey On Dec 17, 2007 4:12 PM, Jari Williamsson wrote: > Tom Norian wrote: > > > How do I divide a number (integer) by 2 and get a result that is like: > > > > 5/2 I want 3 > > 6/2 I want 3 > > 7/2 I want 4 > > Here's another way, one integer division, but 2 instructions: > > a = 5.divmod(2) > result = a[1] + a[2] > > > Best regards, > > Jari Williamsson > > -- http://www.coreyhaines.com The Internet's Premiere source of information about Corey Haines