Jean-Marc Sac-Epee on Thu, 28 Aug 2014 09:21:42 +0200


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

Re: isinteger


Le 28/08/2014 09:15, Josef Eschgfaeller a écrit :
Is there already a function for this in Pari?

\\ Tests if x is integer.
isinteger (x) = floor(x)==x

\\ For rational x.
isinteger (x) = denominator(x)==1

Thanks
Josef Eschgfaeller

? isinteger(n)=type(n)=="t_INT"
%2 = (n)->type(n)=="t_INT"
? isinteger(3.3)
%3 = 0
? isinteger(3)
%4 = 1


( http://pari.math.u-bordeaux.fr/archives/pari-dev-0207/msg00064.html )

JM

--
Jean-Marc Sac-Epée, Ingénieur de Recherche en Calcul Scientifique,
Institut Élie Cartan de Lorraine, UMR 7502,
http://iecl.univ-lorraine.fr/~Jean-Marc.Sac-Epee
Univ de Lorraine, Metz   ("\-''-/").___..--''"`-.
Tél 03 87 54 72 69        (`@_ @  )   `-.  (     ).`-.__.`)
                           (_Y_.)'  ._   )  `._ `. `-..-''
                            `--'_..-_/  /--'_.' ,'