On Wed, Aug 13, 2003 at 09:54:20AM -0400, Bernie Cosell wrote:
> On 13 Aug 2003 at 14:46, Paul Makepeace wrote:
> 
> > This isn't really perl, but it might be mildly fun for a few seconds:
> > 
> >   $len += $page_size - $len % $page_size if $len % $page_size;
> > 
> > Any way of doing this in a single arithmetic expression, without the if?
> 
> How about:
> 
>    $len = int(($len + $page_size-1) / $page_size) ;

Yep. (Altho ITYM,

  $len = int(($len + $page_size-1) / $page_size) * $page_size;

)

Paul

-- 
Paul Makepeace ....................................... http://paulm.com/

"What is elephant? Palak Aloo over rice."
   -- http://paulm.com/toys/surrealism/

Reply via email to