Bill Allombert on Mon, 23 Sep 2002 16:09:07 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: New GP user


On Sun, Sep 22, 2002 at 05:09:54PM +0200, Thomas Baruchel wrote:
> Hi,
> 
> I'm very new to Pari-GP. I used bc/calc/aribas before, but I
> just switched to GP, because of LLL and other features ;-)
> 
> Here are my first troubles:
>   a) I wrote a function which approximates a real number
>      by computing an integer divisions (two huge integers).
>      For me, it has no sense to get
>        f(x) = 1249999999999999999999/10000000000000000000000
The quotient of two integers is a rational number.

>      (in fact it is much more ugly because denominator is a
>      huge prime number).
>      The best I found is to return:
>        a/b+.0
>      is it the best way ?
It is the best way! It is usually written "a/b+0." or even "a/b+.", though I do
not like '.' standing for '0.'.

>   b) 'calc' has a 'swap' feature:
>      swap(a,b) in order to exchange the value of a and b
>      With GP, I couldn't find better than:
>        t=a;
>        a=b;
>        b=t;
>      is there a more elegant way of doing it ?
No, there isn't. Sorry!

Cheers,

Bill.