> < ^ Date: Wed, 20 Mar 2002 13:17:33 +0000
> < ^ From: Steve Linton <sal@dcs.st-and.ac.uk >
< ^ Subject: Re: division problem

Dear GAP Forum,

Ozgu CAN asked:

I have a division operation in my code. But GAP doesn't provide it.
Gives the error below : List Assignment: <position> must be a
positive integer(not a rational) How can i pass this error?


Ozgu CAN Research Assistant

I suspect he (or she, I'm sorry I don't recognise the name Ozgu) has code something like

n := 3;
d:= 2;
x := n/d; 

This will fail, because in GAP, division with / is exact, so that n/d (3/2) is
the rational number 3/2 ( that is 1 1/2) and not (as it would be in C, for
instance) its integer part, 1.

Note that 4/2 is the integer 2, so the problem only arises when the division
is not exact.

The solution is to use the general function Int, to extract the integer part
of the rational, so access

l [Int(x)]

instead of l[x], or to use the QuoInt function to do integer division, as in:

x := QuoInt(n,d);

Both Int and QuoInt are described in the documentation.

Steve Linton

> < [top]