[Maxima] check if a number is rational
pdl at johnlapeyre.com
Sat May 15 18:58:29 CDT 2010
> Dear list,
> I want to check if a number is rational. If I use
> featurep(2/3, rational);
> I get the answer false. Can someone explain this behaviour to me?
> (featurep(sqrt(2), real), however, yields true).
Maybe something like this is close ...
if numberp(expr) and (not atom(expr)) and op(expr) = "/"
I think it gets literal rational numbers.
This says that integers are not rational, which is not mathematically correct,
but may be what you want, and can be corrected if not.
More information about the Maxima