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
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
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>