John Cremona on Thu, 10 Sep 2020 15:53:28 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: gp2c question |
Thanks for the quick reply, Bill! I'm not worried about the warning, as long as nothing actually bad is happening. I had tried changing the constants 1 and 2 in the expression to 1.0 and 2.0, but there were still these warnings. John On Thu, 10 Sep 2020 at 14:42, Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> wrote: > > On Thu, Sep 10, 2020 at 02:05:55PM +0100, John Cremona wrote: > > I have a gp function which I am running using gp2c. In the function I > > have the lines > > > > p = 20.0; > > a = random(p)*2 -1; > > > > since I want a to be a random real in the balanced unit internal > > [-1,1]. (I hope that is correct gp: ?random does not mention the > > possibility of an argument of type t_REAL, but ??random does.) > > > > Both p and are declared in a my() statement as type real with > > my(p:real, a:real, ...). The second line above causes a warning from > > gp2c > > > > Warning:MCq.gp:9: Assignement to a less precise type: real<-gen > > a=(random(p)*2)-1 > > > > Should I worry about that? And surely the right and left hand sides > > have the same type anyway? > > The issue is that gp2c currently does not know that random(real) is a > real, and it does not know that real*2 is a real either, because it uses > a rule 'real*int' and real*0 is not a real. > > You can shut up the warning by adding an explicit cast: > a=((random(p)*2)-1):real > > I will add the necessary data to PARI to shut up the warning. > > Cheers, > Bill >