From: Jim Newton
Subject: integer division
Date: 
Message-ID: <2m5gimFimlgfU1@uni-berlin.de>
what is the best way to do an interger divsion in CL?
I'm using (truncate (/ numerator denominator)) but is
there a better way?

I want 10/4=2 not 2.5.

-jim

From: Paul Dietz
Subject: Re: integer division
Date: 
Message-ID: <40FD9334.F3796021@motorola.com>
Jim Newton wrote:
> 
> what is the best way to do an interger divsion in CL?
> I'm using (truncate (/ numerator denominator)) but is
> there a better way?
> 
> I want 10/4=2 not 2.5.

You can call floor or truncate with two arguments.

(floor 10 4) ==> 2, 2

	Paul
From: Brian Downing
Subject: Re: integer division
Date: 
Message-ID: <vagLc.131415$IQ4.69071@attbi_s02>
In article <··············@uni-berlin.de>, Jim Newton  <·····@rdrop.com> wrote:
> what is the best way to do an interger divsion in CL?
> I'm using (truncate (/ numerator denominator)) but is
> there a better way?
> 
> I want 10/4=2 not 2.5.

TRUNCATE takes a divisor directly.  (truncate 10 4) => 2, 2.  Ignore the
second return value if you don't care about the remainder.

Alternately use FLOOR, CEILING, or ROUND if you want to round a
different way.

http://www.lispworks.com/reference/HyperSpec/Body/f_floorc.htm

-bcd
-- 
*** Brian Downing <bdowning at lavos dot net>