From: Jano Svitok Date: 2007-12-18T04:16:36+09:00 Subject: Re: dividing by two and rounding up On Dec 17, 2007 7:51 PM, Lionel Bouton wrote: > Tom Norian wrote: > > [...]I'm thinking perhaps I could test for oddness then add one to the result > > if odd, but that seems kinda a lot of lines for something so simple. > > > > half_periods = 0 > > if num_periods%2 == 1 > > half_periods = num_periods/2 +1 > > else > > half_periods = num_periods/2 > > end > > > > Is there a better way? > > > > Something like this ? (num_periods / 2.0).ceil or (num_periods + 1)/2 if we want to stay with integers.