Is there an is_integer predicate in SWI-Prolog? The problem with integer/1 is that it will convert a rational number to an integer. I want to know if a value is natively an integer. Bonus points if there is a system predicate that will check if a value is a positive, non-zero integer. If not, I’ll just write my own.
There are 3 pages on integer/1. One of them says that it is the same as round/1, which indicates that it will succeed if given a rational number, a behavior I didn’t want so I made this post:
However I tried that in the console and it true. integer(1.1) returns false so you are correct in that I can use integer/1 for my purposes::
25 ?- integer(1.1).
false.
Apparently that doc page is incorrect since it does not function similar to round/1? I couldn’t test this because round/1 does not appear to be defined, at least not be default:
26 ?- round(1.1).
Correct to: "ground(1.1)"? no
ERROR: Undefined procedure: round/1